提交
This commit is contained in:
1 parent
2a4767a014
commit
f269a994f4
61 files changed
+27430
-8
No files matched your search
@@ -0,0 +1,460 @@
|
||||
<!-- 细胞产品价格体系管理 -->
|
||||
<!-- eslint-disable vue/no-v-model-argument -->
|
||||
<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 />
|
||||
</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"
|
||||
@row-dblclick="handleView"
|
||||
>
|
||||
<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="projectName" label="项目名称" min-width="140" align="center" header-align="center" />
|
||||
<el-table-column prop="projectCode" label="项目编码" min-width="120" align="center" header-align="center" />
|
||||
<el-table-column prop="cellTypeName" label="细胞类型名称" min-width="140" align="center" header-align="center" />
|
||||
<el-table-column prop="specText" label="规格" min-width="120" align="center" header-align="center" />
|
||||
<el-table-column prop="unitPrice" label="单价" min-width="100" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
{{ row.unitPrice != null ? `${row.unitPrice} 元` : '-' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="remark" label="备注" min-width="150" align="center" header-align="center" />
|
||||
<el-table-column prop="createTime" label="创建时间" min-width="180" align="center" header-align="center" />
|
||||
<el-table-column label="操作" width="320" fixed="right" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button class="btn-op-item" @click="handleView(row)"
|
||||
><el-icon><View /></el-icon>查看</el-button
|
||||
>
|
||||
<el-button class="btn-op-item primary" @click="handleEdit(row)"
|
||||
><el-icon><Edit /></el-icon>编辑</el-button
|
||||
>
|
||||
<el-button class="btn-op-item" @click="handleDelete(row)"
|
||||
><el-icon><Delete /></el-icon>删除</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="560px"
|
||||
class="dialog-form-layout"
|
||||
align-center
|
||||
destroy-on-close
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
label-position="top"
|
||||
class="price-dialog-form"
|
||||
scroll-to-error
|
||||
:scroll-into-view-options="{ behavior: 'smooth', block: 'center' }"
|
||||
>
|
||||
<div class="form-grid-2">
|
||||
<el-form-item label="项目名称" prop="projectName">
|
||||
<el-input v-model="formData.projectName" placeholder="请输入项目名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="项目编码" prop="projectCode">
|
||||
<el-input v-model="formData.projectCode" placeholder="请输入项目编码" />
|
||||
</el-form-item>
|
||||
<el-form-item label="细胞产品类型" prop="cellProductTypeId">
|
||||
<el-select
|
||||
v-model="formData.cellProductTypeId"
|
||||
placeholder="请选择细胞产品类型"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
@change="handleTypeChange"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in typeOptions"
|
||||
:key="item.id"
|
||||
:label="item.productTypeName"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="规格" prop="specId">
|
||||
<el-select
|
||||
v-model="formData.specId"
|
||||
placeholder="请选择规格"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
@change="handleSpecChange"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in specOptions"
|
||||
:key="item.id"
|
||||
:label="item.specName"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="单价(元)" prop="unitPrice">
|
||||
<el-input-number
|
||||
v-model="formData.unitPrice"
|
||||
:precision="2"
|
||||
:min="0"
|
||||
:controls="false"
|
||||
placeholder="请输入单价"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注">
|
||||
<el-input v-model="formData.remark" type="textarea" :rows="3" placeholder="可选" />
|
||||
</el-form-item>
|
||||
</div>
|
||||
</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" @click="handleSubmit" :loading="submitLoading">
|
||||
<el-icon><Check /></el-icon>
|
||||
确定
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<SystemViewDialog
|
||||
v-model:visible="viewVisible"
|
||||
:title="viewRow?.projectName || '价格详情'"
|
||||
:icon="ScaleToOriginal"
|
||||
:meta="viewRow?.createTime || ''"
|
||||
:sections="viewSections"
|
||||
/>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted, computed } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { Plus, Close, Check, View, Edit, Delete, ScaleToOriginal } from '@element-plus/icons-vue'
|
||||
import SystemViewDialog from '@/components/business/system-view-dialog/index.vue'
|
||||
import { withFullscreenLoading, fullscreenLoadingText } from '@/utils/fullscreen-loading'
|
||||
import {
|
||||
fetchCellProductPriceList,
|
||||
fetchCreateCellProductPrice,
|
||||
fetchUpdateCellProductPrice,
|
||||
fetchDeleteCellProductPrice,
|
||||
fetchCellProductTypeList,
|
||||
fetchCellProductSpecList
|
||||
} from '@/api/admin'
|
||||
|
||||
defineOptions({ name: 'PilotCellProductPrice' })
|
||||
|
||||
// --- Search ---
|
||||
const searchForm = reactive<{ keyword: string }>({ keyword: '' })
|
||||
|
||||
// --- Table ---
|
||||
const tableData = ref<any[]>([])
|
||||
const selectedRows = ref<any[]>([])
|
||||
const loading = ref(false)
|
||||
const pagination = reactive({ page: 1, pageSize: 10, total: 0 })
|
||||
|
||||
// --- Dialog ---
|
||||
const dialogVisible = ref(false)
|
||||
const dialogTitle = ref('新增价格')
|
||||
const isEdit = ref(false)
|
||||
const submitLoading = ref(false)
|
||||
const formRef = ref()
|
||||
const editingId = ref<string | null>(null)
|
||||
|
||||
// --- View ---
|
||||
const viewVisible = ref(false)
|
||||
const viewRow = ref<any>(null)
|
||||
|
||||
// --- Dropdown options ---
|
||||
const typeOptions = ref<any[]>([])
|
||||
const specOptions = ref<any[]>([])
|
||||
|
||||
// --- Form data ---
|
||||
const formData = reactive({
|
||||
projectName: '',
|
||||
projectCode: '',
|
||||
cellProductTypeId: '' as string,
|
||||
cellTypeCode: '',
|
||||
cellTypeName: '',
|
||||
specId: '' as string,
|
||||
specText: '',
|
||||
unitPrice: null as number | null,
|
||||
remark: ''
|
||||
})
|
||||
|
||||
const formRules = {
|
||||
projectName: [{ required: true, message: '请输入项目名称', trigger: 'blur' }],
|
||||
projectCode: [{ required: true, message: '请输入项目编码', trigger: 'blur' }]
|
||||
}
|
||||
|
||||
// --- Selection ---
|
||||
const handleSelectionChange = (rows: any[]) => {
|
||||
selectedRows.value = rows
|
||||
}
|
||||
|
||||
// --- View sections ---
|
||||
const viewSections = computed(() => {
|
||||
if (!viewRow.value) return []
|
||||
const row = viewRow.value
|
||||
return [
|
||||
{
|
||||
title: '基本信息',
|
||||
fields: [
|
||||
{ label: '项目名称', value: row.projectName },
|
||||
{ label: '项目编码', value: row.projectCode },
|
||||
{ label: '细胞类型名称', value: row.cellTypeName },
|
||||
{ label: '规格', value: row.specText },
|
||||
{ label: '单价(元)', value: row.unitPrice != null ? row.unitPrice : '-' },
|
||||
{ label: '备注', value: row.remark, span: true }
|
||||
]
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
// --- Load options ---
|
||||
async function loadOptions() {
|
||||
const [typeRes, specRes] = await Promise.all([
|
||||
fetchCellProductTypeList({ page: 1, pageSize: 100 }),
|
||||
fetchCellProductSpecList({ page: 1, pageSize: 100 })
|
||||
])
|
||||
typeOptions.value = (typeRes as any)?.list || []
|
||||
specOptions.value = (specRes as any)?.list || []
|
||||
}
|
||||
|
||||
// --- Load data ---
|
||||
async function loadData() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await fetchCellProductPriceList({
|
||||
page: pagination.page,
|
||||
pageSize: pagination.pageSize,
|
||||
keyword: searchForm.keyword || undefined
|
||||
})
|
||||
tableData.value = (res as any)?.list || []
|
||||
pagination.total = (res as any)?.total ?? 0
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function handleSearch() {
|
||||
pagination.page = 1
|
||||
loadData()
|
||||
}
|
||||
|
||||
function handleReset() {
|
||||
searchForm.keyword = ''
|
||||
pagination.page = 1
|
||||
loadData()
|
||||
}
|
||||
|
||||
// --- Reset form ---
|
||||
function resetForm() {
|
||||
formData.projectName = ''
|
||||
formData.projectCode = ''
|
||||
formData.cellProductTypeId = ''
|
||||
formData.cellTypeCode = ''
|
||||
formData.cellTypeName = ''
|
||||
formData.specId = ''
|
||||
formData.specText = ''
|
||||
formData.unitPrice = null
|
||||
formData.remark = ''
|
||||
editingId.value = null
|
||||
}
|
||||
|
||||
// --- Select handlers ---
|
||||
function handleTypeChange(val: string) {
|
||||
const selected = typeOptions.value.find((item) => item.id === val)
|
||||
if (selected) {
|
||||
formData.cellTypeCode = selected.productTypeCode || ''
|
||||
formData.cellTypeName = selected.productTypeName || ''
|
||||
} else {
|
||||
formData.cellTypeCode = ''
|
||||
formData.cellTypeName = ''
|
||||
}
|
||||
}
|
||||
|
||||
function handleSpecChange(val: string) {
|
||||
const selected = specOptions.value.find((item) => item.id === val)
|
||||
if (selected) {
|
||||
formData.specText = selected.specName || ''
|
||||
} else {
|
||||
formData.specText = ''
|
||||
}
|
||||
}
|
||||
|
||||
// --- Add ---
|
||||
async function handleAdd() {
|
||||
isEdit.value = false
|
||||
dialogTitle.value = '新增价格'
|
||||
resetForm()
|
||||
dialogVisible.value = true
|
||||
formRef.value?.clearValidate?.()
|
||||
await loadOptions()
|
||||
}
|
||||
|
||||
// --- Edit ---
|
||||
async function handleEdit(row: any) {
|
||||
isEdit.value = true
|
||||
dialogTitle.value = '编辑价格'
|
||||
editingId.value = row.id
|
||||
formData.projectName = row.projectName || ''
|
||||
formData.projectCode = row.projectCode || ''
|
||||
formData.cellProductTypeId = row.cellProductTypeId || ''
|
||||
formData.cellTypeCode = row.cellTypeCode || ''
|
||||
formData.cellTypeName = row.cellTypeName || ''
|
||||
formData.specId = row.specId || ''
|
||||
formData.specText = row.specText || ''
|
||||
formData.unitPrice = row.unitPrice ?? null
|
||||
formData.remark = row.remark || ''
|
||||
dialogVisible.value = true
|
||||
formRef.value?.clearValidate?.()
|
||||
await loadOptions()
|
||||
}
|
||||
|
||||
// --- Submit ---
|
||||
async function handleSubmit() {
|
||||
await formRef.value?.validate?.()
|
||||
submitLoading.value = true
|
||||
try {
|
||||
const payload = {
|
||||
projectName: formData.projectName.trim(),
|
||||
projectCode: formData.projectCode.trim(),
|
||||
cellProductTypeId: formData.cellProductTypeId || undefined,
|
||||
cellTypeCode: formData.cellTypeCode || undefined,
|
||||
cellTypeName: formData.cellTypeName || undefined,
|
||||
specId: formData.specId || undefined,
|
||||
specText: formData.specText || undefined,
|
||||
unitPrice: formData.unitPrice ?? undefined,
|
||||
remark: formData.remark?.trim() || undefined
|
||||
}
|
||||
if (isEdit.value && editingId.value) {
|
||||
await fetchUpdateCellProductPrice(editingId.value, payload)
|
||||
} else {
|
||||
await fetchCreateCellProductPrice(payload)
|
||||
}
|
||||
ElMessage.success(isEdit.value ? '更新成功' : '创建成功')
|
||||
dialogVisible.value = false
|
||||
await loadData()
|
||||
} catch {
|
||||
/* 校验或接口错误已由全局处理 */
|
||||
} finally {
|
||||
submitLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// --- View ---
|
||||
function handleView(row: any) {
|
||||
viewRow.value = row
|
||||
viewVisible.value = true
|
||||
}
|
||||
|
||||
// --- Delete ---
|
||||
async function handleDelete(row: any) {
|
||||
await ElMessageBox.confirm('确定要删除该价格记录吗?', '提示', { type: 'warning' })
|
||||
await fetchDeleteCellProductPrice(row.id)
|
||||
ElMessage.success('删除成功')
|
||||
await loadData()
|
||||
}
|
||||
|
||||
// --- Batch delete ---
|
||||
async function handleBatchDelete() {
|
||||
const ids = selectedRows.value.map((r) => r.id)
|
||||
if (!ids.length) return
|
||||
await ElMessageBox.confirm(`确定删除选中的 ${ids.length} 条记录吗?`, '提示', { type: 'warning' })
|
||||
await withFullscreenLoading(async () => {
|
||||
for (const id of ids) {
|
||||
await fetchDeleteCellProductPrice(id)
|
||||
}
|
||||
ElMessage.success('批量删除成功')
|
||||
selectedRows.value = []
|
||||
await loadData()
|
||||
}, fullscreenLoadingText.batchDelete)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadData()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.price-dialog-form {
|
||||
:deep(.el-form-item) {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,327 @@
|
||||
<!-- 细胞产品规格管理 -->
|
||||
<!-- eslint-disable vue/no-v-model-argument -->
|
||||
<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 />
|
||||
</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"
|
||||
@row-dblclick="handleView"
|
||||
>
|
||||
<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="specCode" label="规格编码" min-width="120" align="center" header-align="center" />
|
||||
<el-table-column prop="specName" label="规格名称" min-width="150" align="center" header-align="center" />
|
||||
<el-table-column prop="remark" label="备注" min-width="150" align="center" header-align="center" />
|
||||
<el-table-column prop="createTime" label="创建时间" min-width="180" align="center" header-align="center" />
|
||||
<el-table-column label="操作" width="320" fixed="right" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button class="btn-op-item" @click="handleView(row)"
|
||||
><el-icon><View /></el-icon>查看</el-button
|
||||
>
|
||||
<el-button class="btn-op-item primary" @click="handleEdit(row)"
|
||||
><el-icon><Edit /></el-icon>编辑</el-button
|
||||
>
|
||||
<el-button class="btn-op-item" @click="handleDelete(row)"
|
||||
><el-icon><Delete /></el-icon>删除</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="560px"
|
||||
class="dialog-form-layout"
|
||||
align-center
|
||||
destroy-on-close
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
label-position="top"
|
||||
class="spec-dialog-form"
|
||||
scroll-to-error
|
||||
:scroll-into-view-options="{ behavior: 'smooth', block: 'center' }"
|
||||
>
|
||||
<div class="form-grid-2">
|
||||
<el-form-item label="规格编码" prop="specCode">
|
||||
<el-input v-model="formData.specCode" placeholder="请输入规格编码" />
|
||||
</el-form-item>
|
||||
<el-form-item label="规格名称" prop="specName">
|
||||
<el-input v-model="formData.specName" placeholder="请输入规格名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="备注">
|
||||
<el-input v-model="formData.remark" placeholder="可选" />
|
||||
</el-form-item>
|
||||
</div>
|
||||
</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" @click="handleSubmit" :loading="submitLoading">
|
||||
<el-icon><Check /></el-icon>
|
||||
确定
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<SystemViewDialog
|
||||
v-model:visible="viewVisible"
|
||||
:title="viewRow?.specName || '规格详情'"
|
||||
:icon="ScaleToOriginal"
|
||||
:meta="viewRow?.createTime || ''"
|
||||
:sections="viewSections"
|
||||
/>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted, computed } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { Plus, Close, Check, View, Edit, Delete, ScaleToOriginal } from '@element-plus/icons-vue'
|
||||
import SystemViewDialog from '@/components/business/system-view-dialog/index.vue'
|
||||
import { withFullscreenLoading, fullscreenLoadingText } from '@/utils/fullscreen-loading'
|
||||
import {
|
||||
fetchCellProductSpecList,
|
||||
fetchCreateCellProductSpec,
|
||||
fetchUpdateCellProductSpec,
|
||||
fetchDeleteCellProductSpec
|
||||
} from '@/api/admin'
|
||||
|
||||
defineOptions({ name: 'PilotCellProductSpec' })
|
||||
|
||||
const searchForm = reactive<{ keyword: string }>({ keyword: '' })
|
||||
const tableData = ref<Api.CellProductSpec.CellProductSpecItem[]>([])
|
||||
const selectedRows = ref<Api.CellProductSpec.CellProductSpecItem[]>([])
|
||||
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 viewVisible = ref(false)
|
||||
const viewRow = ref<Api.CellProductSpec.CellProductSpecItem | null>(null)
|
||||
|
||||
const formData = reactive({
|
||||
specCode: '',
|
||||
specName: '',
|
||||
remark: ''
|
||||
})
|
||||
|
||||
const formRules = {
|
||||
specCode: [{ required: true, message: '请输入规格编码', trigger: 'blur' }],
|
||||
specName: [{ required: true, message: '请输入规格名称', trigger: 'blur' }]
|
||||
}
|
||||
|
||||
const handleSelectionChange = (rows: Api.CellProductSpec.CellProductSpecItem[]) => {
|
||||
selectedRows.value = rows
|
||||
}
|
||||
|
||||
const viewSections = computed(() => {
|
||||
if (!viewRow.value) return []
|
||||
const row = viewRow.value
|
||||
return [
|
||||
{
|
||||
title: '基本信息',
|
||||
fields: [
|
||||
{ label: '规格编码', value: row.specCode },
|
||||
{ label: '规格名称', value: row.specName },
|
||||
{ label: '备注', value: row.remark, span: true }
|
||||
]
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
async function loadData() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await fetchCellProductSpecList({
|
||||
page: pagination.page,
|
||||
pageSize: pagination.pageSize,
|
||||
keyword: searchForm.keyword || undefined
|
||||
})
|
||||
tableData.value = res.list || []
|
||||
pagination.total = res.total ?? 0
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function handleSearch() {
|
||||
pagination.page = 1
|
||||
loadData()
|
||||
}
|
||||
|
||||
function handleReset() {
|
||||
searchForm.keyword = ''
|
||||
pagination.page = 1
|
||||
loadData()
|
||||
}
|
||||
|
||||
function resetForm() {
|
||||
formData.specCode = ''
|
||||
formData.specName = ''
|
||||
formData.remark = ''
|
||||
editingId.value = null
|
||||
}
|
||||
|
||||
function handleAdd() {
|
||||
isEdit.value = false
|
||||
dialogTitle.value = '新增规格'
|
||||
resetForm()
|
||||
dialogVisible.value = true
|
||||
formRef.value?.clearValidate?.()
|
||||
}
|
||||
|
||||
function handleEdit(row: Api.CellProductSpec.CellProductSpecItem) {
|
||||
isEdit.value = true
|
||||
dialogTitle.value = '编辑规格'
|
||||
editingId.value = row.id
|
||||
formData.specCode = row.specCode || ''
|
||||
formData.specName = row.specName || ''
|
||||
formData.remark = row.remark || ''
|
||||
dialogVisible.value = true
|
||||
formRef.value?.clearValidate?.()
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
await formRef.value?.validate?.()
|
||||
submitLoading.value = true
|
||||
try {
|
||||
const payload = {
|
||||
specCode: formData.specCode.trim(),
|
||||
specName: formData.specName.trim(),
|
||||
remark: formData.remark?.trim() || undefined
|
||||
}
|
||||
if (isEdit.value && editingId.value) {
|
||||
await fetchUpdateCellProductSpec(editingId.value, payload)
|
||||
} else {
|
||||
await fetchCreateCellProductSpec(payload)
|
||||
}
|
||||
ElMessage.success(isEdit.value ? '更新成功' : '创建成功')
|
||||
dialogVisible.value = false
|
||||
await loadData()
|
||||
} catch {
|
||||
/* 校验或接口错误已由全局处理 */
|
||||
} finally {
|
||||
submitLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function handleView(row: Api.CellProductSpec.CellProductSpecItem) {
|
||||
viewRow.value = row
|
||||
viewVisible.value = true
|
||||
}
|
||||
|
||||
async function handleDelete(row: Api.CellProductSpec.CellProductSpecItem) {
|
||||
await ElMessageBox.confirm('确定要删除该规格吗?', '提示', { type: 'warning' })
|
||||
await fetchDeleteCellProductSpec(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' })
|
||||
await withFullscreenLoading(async () => {
|
||||
for (const id of ids) {
|
||||
await fetchDeleteCellProductSpec(id)
|
||||
}
|
||||
ElMessage.success('批量删除成功')
|
||||
selectedRows.value = []
|
||||
await loadData()
|
||||
}, fullscreenLoadingText.batchDelete)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadData()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.spec-dialog-form {
|
||||
:deep(.el-form-item) {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,327 @@
|
||||
<!-- 细胞产品类型管理 -->
|
||||
<!-- eslint-disable vue/no-v-model-argument -->
|
||||
<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 />
|
||||
</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"
|
||||
@row-dblclick="handleView"
|
||||
>
|
||||
<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="productTypeCode" label="类型编码" min-width="120" align="center" header-align="center" />
|
||||
<el-table-column prop="productTypeName" label="类型名称" min-width="150" align="center" header-align="center" />
|
||||
<el-table-column prop="remark" label="备注" min-width="150" align="center" header-align="center" />
|
||||
<el-table-column prop="createTime" label="创建时间" min-width="180" align="center" header-align="center" />
|
||||
<el-table-column label="操作" width="320" fixed="right" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button class="btn-op-item" @click="handleView(row)"
|
||||
><el-icon><View /></el-icon>查看</el-button
|
||||
>
|
||||
<el-button class="btn-op-item primary" @click="handleEdit(row)"
|
||||
><el-icon><Edit /></el-icon>编辑</el-button
|
||||
>
|
||||
<el-button class="btn-op-item" @click="handleDelete(row)"
|
||||
><el-icon><Delete /></el-icon>删除</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="560px"
|
||||
class="dialog-form-layout"
|
||||
align-center
|
||||
destroy-on-close
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
label-position="top"
|
||||
class="type-dialog-form"
|
||||
scroll-to-error
|
||||
:scroll-into-view-options="{ behavior: 'smooth', block: 'center' }"
|
||||
>
|
||||
<div class="form-grid-2">
|
||||
<el-form-item label="类型编码" prop="productTypeCode">
|
||||
<el-input v-model="formData.productTypeCode" placeholder="请输入类型编码" />
|
||||
</el-form-item>
|
||||
<el-form-item label="类型名称" prop="productTypeName">
|
||||
<el-input v-model="formData.productTypeName" placeholder="请输入类型名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="备注">
|
||||
<el-input v-model="formData.remark" placeholder="可选" />
|
||||
</el-form-item>
|
||||
</div>
|
||||
</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" @click="handleSubmit" :loading="submitLoading">
|
||||
<el-icon><Check /></el-icon>
|
||||
确定
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<SystemViewDialog
|
||||
v-model:visible="viewVisible"
|
||||
:title="viewRow?.productTypeName || '类型详情'"
|
||||
:icon="ScaleToOriginal"
|
||||
:meta="viewRow?.createTime || ''"
|
||||
:sections="viewSections"
|
||||
/>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted, computed } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { Plus, Close, Check, View, Edit, Delete, ScaleToOriginal } from '@element-plus/icons-vue'
|
||||
import SystemViewDialog from '@/components/business/system-view-dialog/index.vue'
|
||||
import { withFullscreenLoading, fullscreenLoadingText } from '@/utils/fullscreen-loading'
|
||||
import {
|
||||
fetchCellProductTypeList,
|
||||
fetchCreateCellProductType,
|
||||
fetchUpdateCellProductType,
|
||||
fetchDeleteCellProductType
|
||||
} from '@/api/admin'
|
||||
|
||||
defineOptions({ name: 'PilotCellProductType' })
|
||||
|
||||
const searchForm = reactive<{ keyword: string }>({ keyword: '' })
|
||||
const tableData = ref<Api.CellProductType.CellProductTypeItem[]>([])
|
||||
const selectedRows = ref<Api.CellProductType.CellProductTypeItem[]>([])
|
||||
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 viewVisible = ref(false)
|
||||
const viewRow = ref<Api.CellProductType.CellProductTypeItem | null>(null)
|
||||
|
||||
const formData = reactive({
|
||||
productTypeCode: '',
|
||||
productTypeName: '',
|
||||
remark: ''
|
||||
})
|
||||
|
||||
const formRules = {
|
||||
productTypeCode: [{ required: true, message: '请输入类型编码', trigger: 'blur' }],
|
||||
productTypeName: [{ required: true, message: '请输入类型名称', trigger: 'blur' }]
|
||||
}
|
||||
|
||||
const handleSelectionChange = (rows: Api.CellProductType.CellProductTypeItem[]) => {
|
||||
selectedRows.value = rows
|
||||
}
|
||||
|
||||
const viewSections = computed(() => {
|
||||
if (!viewRow.value) return []
|
||||
const row = viewRow.value
|
||||
return [
|
||||
{
|
||||
title: '基本信息',
|
||||
fields: [
|
||||
{ label: '类型编码', value: row.productTypeCode },
|
||||
{ label: '类型名称', value: row.productTypeName },
|
||||
{ label: '备注', value: row.remark, span: true }
|
||||
]
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
async function loadData() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await fetchCellProductTypeList({
|
||||
page: pagination.page,
|
||||
pageSize: pagination.pageSize,
|
||||
keyword: searchForm.keyword || undefined
|
||||
})
|
||||
tableData.value = res.list || []
|
||||
pagination.total = res.total ?? 0
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function handleSearch() {
|
||||
pagination.page = 1
|
||||
loadData()
|
||||
}
|
||||
|
||||
function handleReset() {
|
||||
searchForm.keyword = ''
|
||||
pagination.page = 1
|
||||
loadData()
|
||||
}
|
||||
|
||||
function resetForm() {
|
||||
formData.productTypeCode = ''
|
||||
formData.productTypeName = ''
|
||||
formData.remark = ''
|
||||
editingId.value = null
|
||||
}
|
||||
|
||||
function handleAdd() {
|
||||
isEdit.value = false
|
||||
dialogTitle.value = '新增类型'
|
||||
resetForm()
|
||||
dialogVisible.value = true
|
||||
formRef.value?.clearValidate?.()
|
||||
}
|
||||
|
||||
function handleEdit(row: Api.CellProductType.CellProductTypeItem) {
|
||||
isEdit.value = true
|
||||
dialogTitle.value = '编辑类型'
|
||||
editingId.value = row.id
|
||||
formData.productTypeCode = row.productTypeCode || ''
|
||||
formData.productTypeName = row.productTypeName || ''
|
||||
formData.remark = row.remark || ''
|
||||
dialogVisible.value = true
|
||||
formRef.value?.clearValidate?.()
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
await formRef.value?.validate?.()
|
||||
submitLoading.value = true
|
||||
try {
|
||||
const payload = {
|
||||
productTypeCode: formData.productTypeCode.trim(),
|
||||
productTypeName: formData.productTypeName.trim(),
|
||||
remark: formData.remark?.trim() || undefined
|
||||
}
|
||||
if (isEdit.value && editingId.value) {
|
||||
await fetchUpdateCellProductType(editingId.value, payload)
|
||||
} else {
|
||||
await fetchCreateCellProductType(payload)
|
||||
}
|
||||
ElMessage.success(isEdit.value ? '更新成功' : '创建成功')
|
||||
dialogVisible.value = false
|
||||
await loadData()
|
||||
} catch {
|
||||
/* 校验或接口错误已由全局处理 */
|
||||
} finally {
|
||||
submitLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function handleView(row: Api.CellProductType.CellProductTypeItem) {
|
||||
viewRow.value = row
|
||||
viewVisible.value = true
|
||||
}
|
||||
|
||||
async function handleDelete(row: Api.CellProductType.CellProductTypeItem) {
|
||||
await ElMessageBox.confirm('确定要删除该类型吗?', '提示', { type: 'warning' })
|
||||
await fetchDeleteCellProductType(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' })
|
||||
await withFullscreenLoading(async () => {
|
||||
for (const id of ids) {
|
||||
await fetchDeleteCellProductType(id)
|
||||
}
|
||||
ElMessage.success('批量删除成功')
|
||||
selectedRows.value = []
|
||||
await loadData()
|
||||
}, fullscreenLoadingText.batchDelete)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadData()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.type-dialog-form {
|
||||
:deep(.el-form-item) {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,815 @@
|
||||
<!-- 渠道信息 — 只读查看(样式对齐采集协议单 ProtocolViewDialog) -->
|
||||
<template>
|
||||
<div class="channel-view-dialog-root">
|
||||
<el-dialog
|
||||
:model-value="modelValue"
|
||||
:title="dialogTitle"
|
||||
width="1100px"
|
||||
class="dialog-form-layout channel-view-dialog"
|
||||
align-center
|
||||
destroy-on-close
|
||||
:close-on-click-modal="false"
|
||||
@update:model-value="emit('update:modelValue', $event)"
|
||||
@closed="handleClosed"
|
||||
>
|
||||
<div v-loading="loading" class="channel-view-body">
|
||||
<template v-if="channel">
|
||||
<div class="detail-tabs">
|
||||
<div
|
||||
v-for="tab in viewTabs"
|
||||
:key="tab.key"
|
||||
class="detail-tab"
|
||||
:class="{ active: activeTab === tab.key }"
|
||||
@click="scrollToSection(tab.key)"
|
||||
>
|
||||
{{ tab.label }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="kpi-strip">
|
||||
<div class="kpi-card">
|
||||
<div class="kpi-label">渠道名称</div>
|
||||
<div class="kpi-value">{{ dash(channel.channelName) }}</div>
|
||||
</div>
|
||||
<div class="kpi-card">
|
||||
<div class="kpi-label">渠道类型</div>
|
||||
<div class="kpi-value">
|
||||
<span class="badge" :class="channelTypeBadgeClass(channel.channelType)">
|
||||
{{ channelTypeLabel(channel.channelType) }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="kpi-card">
|
||||
<div class="kpi-label">联系人</div>
|
||||
<div class="kpi-value">{{ dash(channel.contactName) }}</div>
|
||||
</div>
|
||||
<div class="kpi-card">
|
||||
<div class="kpi-label">创建时间</div>
|
||||
<div class="kpi-value">{{ dash(channel.createTime) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="view-section-basic" class="section-card section-card--white">
|
||||
<div class="section-title"><h3>基础信息</h3></div>
|
||||
<div class="data-grid data-grid--3">
|
||||
<div class="data-item">
|
||||
<div class="data-label">渠道名称</div>
|
||||
<div class="data-value">{{ dash(channel.channelName) }}</div>
|
||||
</div>
|
||||
<div class="data-item">
|
||||
<div class="data-label">统一社会信用代码</div>
|
||||
<div class="data-value">{{ dash(channel.creditCode) }}</div>
|
||||
</div>
|
||||
<div class="data-item">
|
||||
<div class="data-label">渠道类型</div>
|
||||
<div class="data-value">
|
||||
<span class="badge" :class="channelTypeBadgeClass(channel.channelType)">
|
||||
{{ channelTypeLabel(channel.channelType) }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="data-item">
|
||||
<div class="data-label">联系人</div>
|
||||
<div class="data-value">{{ dash(channel.contactName) }}</div>
|
||||
</div>
|
||||
<div class="data-item">
|
||||
<div class="data-label">联系电话</div>
|
||||
<div class="data-value">{{ dash(channel.contactPhone) }}</div>
|
||||
</div>
|
||||
<div class="data-item">
|
||||
<div class="data-label">联系邮箱</div>
|
||||
<div class="data-value">{{ dash(channel.contactEmail) }}</div>
|
||||
</div>
|
||||
<div class="data-item">
|
||||
<div class="data-label">创建时间</div>
|
||||
<div class="data-value">{{ dash(channel.createTime) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="protocolAttachmentFiles.length" class="attachment-row">
|
||||
<div class="data-label">渠道协议附件</div>
|
||||
<ProtocolAttachmentReadonly
|
||||
:files="protocolAttachmentFiles"
|
||||
@preview="openPreview"
|
||||
@download="downloadFile"
|
||||
/>
|
||||
</div>
|
||||
<div v-if="channel.remark" class="remark-row">
|
||||
<div class="data-item data-item--full">
|
||||
<div class="data-label">备注</div>
|
||||
<div class="data-value data-value--muted">{{ dash(channel.remark) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="view-section-invoice" class="section-card section-card--green">
|
||||
<div class="section-title"><h3>开票信息</h3></div>
|
||||
<div v-if="invoiceList.length" class="sub-cards">
|
||||
<div v-for="(row, idx) in invoiceList" :key="row.id || idx" class="sub-card">
|
||||
<div class="sub-card-header">
|
||||
<h4>{{ row.companyName || '未命名' }}</h4>
|
||||
</div>
|
||||
<div class="data-grid data-grid--2">
|
||||
<div v-if="row.taxNo" class="data-item">
|
||||
<div class="data-label">税号</div>
|
||||
<div class="data-value">{{ dash(row.taxNo) }}</div>
|
||||
</div>
|
||||
<div v-if="row.phone || row.companyPhone" class="data-item">
|
||||
<div class="data-label">电话</div>
|
||||
<div class="data-value">{{ dash(row.phone || row.companyPhone) }}</div>
|
||||
</div>
|
||||
<div v-if="row.companyAddress" class="data-item data-item--full">
|
||||
<div class="data-label">单位地址</div>
|
||||
<div class="data-value data-value--muted">{{ dash(row.companyAddress) }}</div>
|
||||
</div>
|
||||
<div v-if="row.bankName" class="data-item">
|
||||
<div class="data-label">开户银行</div>
|
||||
<div class="data-value">{{ dash(row.bankName) }}</div>
|
||||
</div>
|
||||
<div v-if="row.bankAccount" class="data-item">
|
||||
<div class="data-label">银行账号</div>
|
||||
<div class="data-value">{{ dash(row.bankAccount) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<el-empty v-else description="暂无开票信息" :image-size="48" />
|
||||
</div>
|
||||
|
||||
<div id="view-section-mail" class="section-card section-card--white">
|
||||
<div class="section-title"><h3>邮寄地址</h3></div>
|
||||
<div v-if="mailList.length" class="sub-cards">
|
||||
<div v-for="(row, idx) in mailList" :key="row.id || idx" class="sub-card">
|
||||
<div class="sub-card-header">
|
||||
<h4>{{ row.mailAddress || '未命名' }}</h4>
|
||||
</div>
|
||||
<div class="data-grid data-grid--2">
|
||||
<div v-if="row.mailContactName || row.mailContact" class="data-item">
|
||||
<div class="data-label">联系人</div>
|
||||
<div class="data-value">{{ dash(row.mailContactName || row.mailContact) }}</div>
|
||||
</div>
|
||||
<div v-if="row.mailContactPhone || row.mailPhone" class="data-item">
|
||||
<div class="data-label">联系电话</div>
|
||||
<div class="data-value">{{ dash(row.mailContactPhone || row.mailPhone) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<el-empty v-else description="暂无邮寄地址" :image-size="48" />
|
||||
</div>
|
||||
|
||||
<div id="view-section-agreement" class="section-card section-card--gray">
|
||||
<div class="section-title"><h3>协议信息</h3></div>
|
||||
<div v-if="agreementList.length" class="agreement-cards">
|
||||
<div
|
||||
v-for="(agr, idx) in agreementList"
|
||||
:key="agr.id || idx"
|
||||
class="agreement-card"
|
||||
>
|
||||
<div class="agreement-card__header">
|
||||
<div class="agreement-card__tags">
|
||||
<span class="badge" :class="agreementTypeBadgeClass(agr.agreementType)">
|
||||
{{ agreementTypeLabel(agr.agreementType) }}
|
||||
</span>
|
||||
<span class="badge" :class="agreementStatusBadgeClass(agr.status)">
|
||||
{{ agreementStatusLabel(agr.status) }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="data-grid data-grid--4">
|
||||
<div v-if="agr.settlementType" class="data-item">
|
||||
<div class="data-label">结算方式</div>
|
||||
<div class="data-value">
|
||||
<span class="badge" :class="settlementTypeBadgeClass(agr.settlementType)">
|
||||
{{ settlementTypeLabel(agr.settlementType) }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="agr.creditLimit != null" class="data-item">
|
||||
<div class="data-label">授信额度(元)</div>
|
||||
<div class="data-value data-value--price">{{ dash(agr.creditLimit) }}</div>
|
||||
</div>
|
||||
<div v-if="agr.effectiveDate" class="data-item">
|
||||
<div class="data-label">生效日期</div>
|
||||
<div class="data-value">{{ dash(agr.effectiveDate) }}</div>
|
||||
</div>
|
||||
<div v-if="agr.expiryDate" class="data-item">
|
||||
<div class="data-label">到期日期</div>
|
||||
<div class="data-value">{{ dash(agr.expiryDate) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<el-empty v-else description="暂无协议信息" :image-size="48" />
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<template #footer>
|
||||
<el-button class="btn-ghost" @click="emit('update:modelValue', false)">
|
||||
<el-icon><Close /></el-icon>
|
||||
关闭
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog v-model="previewVisible" title="文件预览" width="800px" align-center destroy-on-close>
|
||||
<div v-if="previewType === 'image'" class="preview-container">
|
||||
<img
|
||||
:src="previewUrl"
|
||||
alt="预览"
|
||||
style="max-width: 100%; max-height: 70vh; display: block; margin: 0 auto"
|
||||
/>
|
||||
</div>
|
||||
<div v-else class="preview-container">
|
||||
<video
|
||||
:src="previewUrl"
|
||||
controls
|
||||
style="max-width: 100%; max-height: 70vh; display: block; margin: 0 auto"
|
||||
/>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, ref, watch } from 'vue'
|
||||
import { Close } from '@element-plus/icons-vue'
|
||||
import ProtocolAttachmentReadonly from '@/views/cell-storage/protocol/ProtocolAttachmentReadonly.vue'
|
||||
import {
|
||||
fetchChannelInvoices,
|
||||
fetchChannelMailAddresses,
|
||||
fetchChannelAgreements
|
||||
} from '@/api/admin'
|
||||
|
||||
const props = defineProps<{
|
||||
modelValue: boolean
|
||||
channelId: string | null
|
||||
listRow?: Record<string, any> | null
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:modelValue', val: boolean): void
|
||||
}>()
|
||||
|
||||
const viewTabs = [
|
||||
{ key: 'basic', label: '基础信息' },
|
||||
{ key: 'invoice', label: '开票信息' },
|
||||
{ key: 'mail', label: '邮寄地址' },
|
||||
{ key: 'agreement', label: '协议信息' }
|
||||
] as const
|
||||
|
||||
const channelTypeMap: Record<string, string> = {
|
||||
yy: '医院',
|
||||
hzjg: '合作机构',
|
||||
zs: '诊所',
|
||||
zfjg: '政府机构',
|
||||
qt: '其他'
|
||||
}
|
||||
|
||||
const agreementTypeMap: Record<string, string> = {
|
||||
kyxy: '框架协议',
|
||||
zsxy: '中试协议',
|
||||
lcxy: '临床协议'
|
||||
}
|
||||
|
||||
const settlementTypeMap: Record<string, string> = {
|
||||
yj: '月结',
|
||||
jj: '季结',
|
||||
nj: '年结',
|
||||
dcjs: '单次结算'
|
||||
}
|
||||
|
||||
const agreementStatusMap: Record<string, string> = {
|
||||
dsx: '待生效',
|
||||
sxz: '生效中',
|
||||
yzf: '已作废'
|
||||
}
|
||||
|
||||
const loading = ref(false)
|
||||
const activeTab = ref('basic')
|
||||
const invoiceList = ref<any[]>([])
|
||||
const mailList = ref<any[]>([])
|
||||
const agreementList = ref<any[]>([])
|
||||
|
||||
const channel = computed(() => props.listRow || null)
|
||||
|
||||
const dialogTitle = computed(() => {
|
||||
const name = channel.value?.channelName
|
||||
return name ? `查看渠道 — ${name}` : '查看渠道'
|
||||
})
|
||||
|
||||
const minioBaseUrl = (import.meta.env.VITE_MINIO_BASE_URL || '').replace(/\/$/, '')
|
||||
|
||||
const protocolAttachmentFiles = computed(() => {
|
||||
const urls = String(channel.value?.protocolAttachments || '').trim()
|
||||
if (!urls) return []
|
||||
return urls
|
||||
.split(',')
|
||||
.map((u, i) => {
|
||||
const url = u.trim()
|
||||
if (!url) return null
|
||||
const name = url.includes('/') ? url.split('/').pop() || `附件${i + 1}` : url
|
||||
return { id: `att_${i}`, fileUrl: url, fileName: name, fileSize: 0 }
|
||||
})
|
||||
.filter(Boolean) as Array<Record<string, any>>
|
||||
})
|
||||
|
||||
function dash(val: unknown) {
|
||||
if (val === null || val === undefined || val === '') return '—'
|
||||
return String(val)
|
||||
}
|
||||
|
||||
function channelTypeLabel(type: string) {
|
||||
const key = String(type || '').trim()
|
||||
if (!key) return '—'
|
||||
return channelTypeMap[key] || key
|
||||
}
|
||||
|
||||
function channelTypeBadgeClass(type: string): string {
|
||||
const m: Record<string, string> = {
|
||||
yy: 'badge--blue',
|
||||
hzjg: 'badge--green',
|
||||
zs: 'badge--amber',
|
||||
zfjg: 'badge--red',
|
||||
qt: 'badge--gray'
|
||||
}
|
||||
return m[String(type || '')] || 'badge--gray'
|
||||
}
|
||||
|
||||
function agreementTypeLabel(type: string) {
|
||||
return agreementTypeMap[String(type || '')] || dash(type)
|
||||
}
|
||||
|
||||
function agreementTypeBadgeClass(type: string): string {
|
||||
const m: Record<string, string> = {
|
||||
kyxy: 'badge--blue',
|
||||
zsxy: 'badge--green',
|
||||
lcxy: 'badge--amber'
|
||||
}
|
||||
return m[String(type || '')] || 'badge--gray'
|
||||
}
|
||||
|
||||
function settlementTypeLabel(type: string) {
|
||||
return settlementTypeMap[String(type || '')] || dash(type)
|
||||
}
|
||||
|
||||
function settlementTypeBadgeClass(type: string): string {
|
||||
const m: Record<string, string> = {
|
||||
yj: 'badge--gray',
|
||||
jj: 'badge--green',
|
||||
nj: 'badge--amber',
|
||||
dcjs: 'badge--red'
|
||||
}
|
||||
return m[String(type || '')] || 'badge--gray'
|
||||
}
|
||||
|
||||
function normalizeAgreementRow(row: Record<string, any>) {
|
||||
const status = String(row.agreementStatus ?? row.status ?? 'dsx').trim() || 'dsx'
|
||||
return {
|
||||
...row,
|
||||
settlementType: row.settleMode ?? row.settlementType ?? '',
|
||||
creditLimit: row.creditLimitAmount ?? row.creditLimit ?? null,
|
||||
expiryDate: row.expireDate ?? row.expiryDate ?? '',
|
||||
effectiveDate: row.effectiveDate ?? '',
|
||||
status
|
||||
}
|
||||
}
|
||||
|
||||
function agreementStatusLabel(status: string) {
|
||||
return agreementStatusMap[String(status || '')] || dash(status)
|
||||
}
|
||||
|
||||
function agreementStatusBadgeClass(status: string): string {
|
||||
const m: Record<string, string> = {
|
||||
dsx: 'badge--amber',
|
||||
sxz: 'badge--green',
|
||||
yzf: 'badge--red'
|
||||
}
|
||||
return m[String(status || '')] || 'badge--gray'
|
||||
}
|
||||
|
||||
function fullFileUrl(suffix: string) {
|
||||
if (!suffix) return ''
|
||||
if (suffix.startsWith('http://') || suffix.startsWith('https://') || suffix.startsWith('/')) {
|
||||
return suffix
|
||||
}
|
||||
return `${minioBaseUrl}/${suffix}`
|
||||
}
|
||||
|
||||
function isVideoFile(file: { fileType?: string; fileName?: string }) {
|
||||
const t = (file.fileType || '').toLowerCase()
|
||||
if (t.startsWith('video/')) return true
|
||||
return /\.(mp4|webm|ogg|mov)$/i.test(file.fileName || '')
|
||||
}
|
||||
|
||||
const previewVisible = ref(false)
|
||||
const previewUrl = ref('')
|
||||
const previewType = ref<'image' | 'video'>('image')
|
||||
|
||||
function openPreview(file: Record<string, any>) {
|
||||
if (!file.fileUrl) return
|
||||
previewUrl.value = fullFileUrl(file.fileUrl)
|
||||
previewType.value = isVideoFile(file) ? 'video' : 'image'
|
||||
previewVisible.value = true
|
||||
}
|
||||
|
||||
function downloadFile(file: Record<string, any>) {
|
||||
const url = fullFileUrl(file.fileUrl)
|
||||
if (!url) return
|
||||
const a = document.createElement('a')
|
||||
a.href = url
|
||||
a.download = file.fileName || ''
|
||||
a.target = '_blank'
|
||||
document.body.appendChild(a)
|
||||
a.click()
|
||||
document.body.removeChild(a)
|
||||
}
|
||||
|
||||
async function loadSubTables() {
|
||||
if (!props.channelId) {
|
||||
invoiceList.value = []
|
||||
mailList.value = []
|
||||
agreementList.value = []
|
||||
return
|
||||
}
|
||||
loading.value = true
|
||||
try {
|
||||
const [invRes, mailRes, agrRes] = await Promise.all([
|
||||
fetchChannelInvoices(props.channelId),
|
||||
fetchChannelMailAddresses(props.channelId),
|
||||
fetchChannelAgreements(props.channelId)
|
||||
])
|
||||
const invRows = Array.isArray(invRes) ? invRes : (invRes as any)?.list || []
|
||||
const mailRows = Array.isArray(mailRes) ? mailRes : (mailRes as any)?.list || []
|
||||
invoiceList.value = invRows.map((row: any) => ({
|
||||
...row,
|
||||
phone: row.companyPhone ?? row.phone ?? '',
|
||||
companyPhone: row.companyPhone ?? row.phone ?? ''
|
||||
}))
|
||||
mailList.value = mailRows.map((row: any) => ({
|
||||
...row,
|
||||
mailContactName: row.mailContact ?? row.mailContactName ?? '',
|
||||
mailContactPhone: row.mailPhone ?? row.mailContactPhone ?? ''
|
||||
}))
|
||||
const agrRows = Array.isArray(agrRes) ? agrRes : (agrRes as any)?.list || []
|
||||
agreementList.value = agrRows.map((row: Record<string, any>) => normalizeAgreementRow(row))
|
||||
} catch {
|
||||
invoiceList.value = []
|
||||
mailList.value = []
|
||||
agreementList.value = []
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function scrollToSection(key: string) {
|
||||
activeTab.value = key
|
||||
nextTick(() => {
|
||||
document
|
||||
.getElementById(`view-section-${key}`)
|
||||
?.scrollIntoView({ behavior: 'smooth', block: 'start' })
|
||||
})
|
||||
}
|
||||
|
||||
function handleClosed() {
|
||||
invoiceList.value = []
|
||||
mailList.value = []
|
||||
agreementList.value = []
|
||||
activeTab.value = 'basic'
|
||||
}
|
||||
|
||||
watch(
|
||||
() => [props.modelValue, props.channelId] as const,
|
||||
([visible, id]) => {
|
||||
if (visible && id) loadSubTables()
|
||||
}
|
||||
)
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.channel-view-body {
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
.detail-tabs {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 1000;
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
background: #f0fdf4;
|
||||
padding: 4px;
|
||||
border-radius: 8px;
|
||||
margin-bottom: 16px;
|
||||
width: fit-content;
|
||||
isolation: isolate;
|
||||
box-shadow: 0 1px 0 #f0fdf4;
|
||||
}
|
||||
|
||||
.detail-tab {
|
||||
padding: 10px 20px;
|
||||
cursor: pointer;
|
||||
border-radius: 6px;
|
||||
font-size: 14px;
|
||||
color: #606266;
|
||||
transition: all 0.3s;
|
||||
|
||||
&.active {
|
||||
background: #fff;
|
||||
color: #059669;
|
||||
font-weight: 500;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
&:hover:not(.active) {
|
||||
color: #059669;
|
||||
}
|
||||
}
|
||||
|
||||
.kpi-strip {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
gap: 16px;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.kpi-card {
|
||||
background: #fff;
|
||||
border-radius: 12px;
|
||||
padding: 18px 20px;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
|
||||
border-left: 3px solid #10b981;
|
||||
transition:
|
||||
transform 0.2s,
|
||||
box-shadow 0.2s;
|
||||
|
||||
&:hover {
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 4px 12px rgba(16, 185, 129, 0.1);
|
||||
}
|
||||
}
|
||||
|
||||
.kpi-label {
|
||||
font-size: 12px;
|
||||
color: #94a3b8;
|
||||
margin-bottom: 6px;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
.kpi-value {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: #1e293b;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.section-card {
|
||||
border-radius: 12px;
|
||||
padding: 22px 24px;
|
||||
margin-bottom: 20px;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
|
||||
transition:
|
||||
transform 0.2s,
|
||||
box-shadow 0.2s;
|
||||
|
||||
&:hover {
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
|
||||
}
|
||||
|
||||
&--white {
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
&--green {
|
||||
background: #f0fdf4;
|
||||
}
|
||||
|
||||
&--gray {
|
||||
background: #f8fafc;
|
||||
}
|
||||
}
|
||||
|
||||
.section-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 18px;
|
||||
padding-bottom: 12px;
|
||||
border-bottom: 1px solid #e2e8f0;
|
||||
|
||||
&::before {
|
||||
content: '';
|
||||
width: 3px;
|
||||
height: 18px;
|
||||
background: #10b981;
|
||||
border-radius: 2px;
|
||||
margin-right: 10px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
h3 {
|
||||
margin: 0;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
color: #1e293b;
|
||||
line-height: 1.4;
|
||||
}
|
||||
}
|
||||
|
||||
.data-grid {
|
||||
display: grid;
|
||||
gap: 14px 20px;
|
||||
|
||||
&--2 {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
&--3 {
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
&--4 {
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
|
||||
.data-item {
|
||||
min-width: 0;
|
||||
|
||||
&--full {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
}
|
||||
|
||||
.data-label {
|
||||
font-size: 12px;
|
||||
color: #94a3b8;
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
|
||||
.data-value {
|
||||
font-size: 14px;
|
||||
color: #1e293b;
|
||||
font-weight: 500;
|
||||
word-break: break-word;
|
||||
|
||||
&--muted {
|
||||
color: #64748b;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
&--price {
|
||||
color: #059669;
|
||||
font-weight: 700;
|
||||
}
|
||||
}
|
||||
|
||||
.badge {
|
||||
display: inline-block;
|
||||
padding: 2px 10px;
|
||||
border-radius: 12px;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
line-height: 1.6;
|
||||
|
||||
&--green {
|
||||
background: #ecfdf5;
|
||||
color: #059669;
|
||||
}
|
||||
|
||||
&--amber {
|
||||
background: #fffbeb;
|
||||
color: #d97706;
|
||||
}
|
||||
|
||||
&--gray {
|
||||
background: #f1f5f9;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
&--red {
|
||||
background: #fef2f2;
|
||||
color: #dc2626;
|
||||
}
|
||||
|
||||
&--blue {
|
||||
background: #eff6ff;
|
||||
color: #2563eb;
|
||||
}
|
||||
}
|
||||
|
||||
.attachment-row {
|
||||
margin-top: 12px;
|
||||
padding-top: 12px;
|
||||
border-top: 1px dashed #e2e8f0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.remark-row {
|
||||
margin-top: 12px;
|
||||
padding-top: 12px;
|
||||
border-top: 1px dashed #e2e8f0;
|
||||
}
|
||||
|
||||
.sub-cards {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.sub-card {
|
||||
background: #fff;
|
||||
border-radius: 10px;
|
||||
padding: 16px 18px;
|
||||
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
|
||||
border: 1px solid rgba(0, 0, 0, 0.03);
|
||||
transition:
|
||||
transform 0.2s,
|
||||
box-shadow 0.2s;
|
||||
|
||||
&:hover {
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.07);
|
||||
}
|
||||
}
|
||||
|
||||
.sub-card-header {
|
||||
margin-bottom: 12px;
|
||||
padding-bottom: 10px;
|
||||
border-bottom: 1px solid #f1f5f9;
|
||||
|
||||
h4 {
|
||||
margin: 0;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: #1e293b;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
.agreement-cards {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.agreement-card {
|
||||
background: #fff;
|
||||
border-radius: 10px;
|
||||
border: 1px solid #e2e8f0;
|
||||
overflow: hidden;
|
||||
transition:
|
||||
border-color 0.2s,
|
||||
box-shadow 0.2s;
|
||||
|
||||
&:hover {
|
||||
border-color: #a7f3d0;
|
||||
box-shadow: 0 2px 12px rgba(16, 185, 129, 0.1);
|
||||
}
|
||||
}
|
||||
|
||||
.agreement-card__header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 12px 18px;
|
||||
background: #f8fafc;
|
||||
border-bottom: 1px solid #e2e8f0;
|
||||
}
|
||||
|
||||
.agreement-card__tags {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.agreement-card .data-grid {
|
||||
padding: 14px 18px;
|
||||
}
|
||||
|
||||
.preview-container {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
@media (max-width: 1200px) {
|
||||
.kpi-strip {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
|
||||
.data-grid--3,
|
||||
.data-grid--4 {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.sub-cards {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,461 @@
|
||||
<!-- 体检机构 — 项目套餐(机构内) -->
|
||||
<!-- eslint-disable vue/no-v-model-argument -->
|
||||
<template>
|
||||
<div class="package-panel">
|
||||
<div class="list-toolbar item-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>
|
||||
</div>
|
||||
</div>
|
||||
<div class="list-body list-wrap item-table-wrap">
|
||||
<el-table
|
||||
class="list-table"
|
||||
:data="tableData"
|
||||
v-loading="loading"
|
||||
stripe
|
||||
row-key="id"
|
||||
max-height="420"
|
||||
@selection-change="(rows) => (selectedRows = rows)"
|
||||
>
|
||||
<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" />
|
||||
<el-table-column prop="packageName" label="套餐名称" min-width="140" align="center" header-align="center" />
|
||||
<el-table-column prop="packageCode" label="套餐编码" min-width="120" align="center" header-align="center" />
|
||||
<el-table-column prop="itemCount" label="项目数" width="80" align="center" header-align="center" />
|
||||
<el-table-column label="合计费用(元)" width="120" align="center" header-align="center">
|
||||
<template #default="{ row }">{{
|
||||
row.totalFee != null ? `¥${row.totalFee}` : '—'
|
||||
}}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="status" label="状态" width="90" align="center">
|
||||
<template #default="{ row }">
|
||||
<span :class="['tag', row.status == '1' ? 'success' : 'muted']">
|
||||
{{ row.status == '1' ? '正常' : '停用' }}
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="remark"
|
||||
label="备注"
|
||||
min-width="120"
|
||||
align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<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-icon><Edit /></el-icon>编辑</el-button
|
||||
>
|
||||
<el-button class="btn-op-item" @click="handleDelete(row)"
|
||||
><el-icon><Delete /></el-icon>删除</el-button
|
||||
>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
<el-dialog
|
||||
v-model="dialogVisible"
|
||||
:title="dialogTitle"
|
||||
width="980px"
|
||||
class="dialog-form-layout"
|
||||
align-center
|
||||
append-to-body
|
||||
destroy-on-close
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
label-position="top"
|
||||
class="package-dialog-form"
|
||||
scroll-to-error
|
||||
>
|
||||
<div class="form-grid-2">
|
||||
<el-form-item label="套餐名称" prop="packageName">
|
||||
<el-input v-model="formData.packageName" placeholder="请输入套餐名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="套餐编码" prop="packageCode">
|
||||
<el-input v-model="formData.packageCode" placeholder="机构内唯一" />
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-radio-group v-model="formData.status">
|
||||
<el-radio value="1">正常</el-radio>
|
||||
<el-radio value="0">停用</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注">
|
||||
<el-input v-model="formData.remark" placeholder="可选" />
|
||||
</el-form-item>
|
||||
</div>
|
||||
</el-form>
|
||||
|
||||
<div class="detail-section">
|
||||
<div class="detail-section-head">
|
||||
<h3 class="detail-section-title">套餐项目明细</h3>
|
||||
<el-button class="btn-main" type="primary" size="small" @click="openProjectSelector">
|
||||
<el-icon><Plus /></el-icon>添加项目
|
||||
</el-button>
|
||||
</div>
|
||||
<el-table :data="detailItems" size="small" class="detail-table" max-height="280">
|
||||
<el-table-column type="index" label="序号" width="55" align="center" />
|
||||
<el-table-column label="项目名称" min-width="160" align="center">
|
||||
<template #default="{ row }">
|
||||
{{ row.projectName }}
|
||||
<span v-if="row.sourceProjectDeleted" class="form-label-tip">源项目已删除</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="项目费用(元)" min-width="120" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-input-number
|
||||
v-model="row.projectFee"
|
||||
:precision="2"
|
||||
:min="0"
|
||||
:controls="false"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="状态" width="90" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<span :class="['tag', row.status == '1' ? 'success' : 'muted']">
|
||||
{{ row.status == '1' ? '正常' : '停用' }}
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" min-width="140" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-input v-model="row.remark" placeholder="可选" clearable />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="260" fixed="right" align="center" header-align="center">
|
||||
<template #default="{ $index }">
|
||||
<el-button class="btn-op-item" @click="detailItems.splice($index, 1)">
|
||||
<el-icon><Delete /></el-icon>删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div class="package-total"
|
||||
>套餐合计:<strong>¥{{ packageTotalFee.toFixed(2) }}</strong></div
|
||||
>
|
||||
</div>
|
||||
|
||||
<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="projectSelectorVisible"
|
||||
title="添加体检项目"
|
||||
width="860px"
|
||||
class="dialog-form-layout"
|
||||
align-center
|
||||
append-to-body
|
||||
destroy-on-close
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<el-input
|
||||
v-model="projectSelectorKeyword"
|
||||
placeholder="搜索项目名称"
|
||||
clearable
|
||||
style="width: 260px; margin-bottom: 12px"
|
||||
/>
|
||||
<el-table
|
||||
:data="filteredProjectList"
|
||||
max-height="360"
|
||||
@selection-change="(rows) => (projectSelectorSelected = rows)"
|
||||
>
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column prop="projectName" label="项目名称" min-width="140" align="center" />
|
||||
<el-table-column label="项目费用(元)" width="110" align="center">
|
||||
<template #default="{ row }">{{
|
||||
row.projectFee != null ? `¥${row.projectFee}` : '—'
|
||||
}}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="status" label="状态" width="90" align="center">
|
||||
<template #default="{ row }">
|
||||
<span :class="['tag', row.status == '1' ? 'success' : 'muted']">
|
||||
{{ row.status == '1' ? '正常' : '停用' }}
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="remark"
|
||||
label="备注"
|
||||
min-width="120"
|
||||
align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
</el-table>
|
||||
<template #footer>
|
||||
<el-button class="btn-ghost" @click="projectSelectorVisible = false">取消</el-button>
|
||||
<el-button
|
||||
class="btn-main"
|
||||
type="primary"
|
||||
:disabled="projectSelectorSelected.length === 0"
|
||||
@click="confirmProjectSelector"
|
||||
>
|
||||
确认添加({{ projectSelectorSelected.length }})
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, computed, watch } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { Plus, Close, Check, Edit, Delete } from '@element-plus/icons-vue'
|
||||
import {
|
||||
fetchCheckupInstitutionPackages,
|
||||
fetchCheckupInstitutionPackageDetail,
|
||||
fetchCreateCheckupInstitutionPackage,
|
||||
fetchUpdateCheckupInstitutionPackage,
|
||||
fetchDeleteCheckupInstitutionPackage,
|
||||
fetchCheckupInstitutionProjects
|
||||
} from '@/api/admin'
|
||||
|
||||
const props = defineProps<{
|
||||
institutionId: string
|
||||
institutionName: string
|
||||
}>()
|
||||
|
||||
const tableData = ref<any[]>([])
|
||||
const selectedRows = ref<any[]>([])
|
||||
const loading = ref(false)
|
||||
|
||||
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 formData = reactive({
|
||||
packageName: '',
|
||||
packageCode: '',
|
||||
status: '1',
|
||||
remark: ''
|
||||
})
|
||||
|
||||
const formRules = {
|
||||
packageName: [{ required: true, message: '请输入套餐名称', trigger: 'blur' }],
|
||||
packageCode: [{ required: true, message: '请输入套餐编码', trigger: 'blur' }],
|
||||
status: [{ required: true, message: '请选择状态', trigger: 'change' }]
|
||||
}
|
||||
|
||||
const detailItems = ref<any[]>([])
|
||||
|
||||
const packageTotalFee = computed(() =>
|
||||
detailItems.value.reduce((sum, row) => sum + (Number(row.projectFee) || 0), 0)
|
||||
)
|
||||
|
||||
const projectSelectorVisible = ref(false)
|
||||
const projectSelectorKeyword = ref('')
|
||||
const projectSelectorList = ref<any[]>([])
|
||||
const projectSelectorSelected = ref<any[]>([])
|
||||
|
||||
const filteredProjectList = computed(() => {
|
||||
const kw = projectSelectorKeyword.value.trim().toLowerCase()
|
||||
const used = new Set(detailItems.value.map((r) => r.checkupInstitutionProjectId))
|
||||
return projectSelectorList.value.filter((row) => {
|
||||
if (row.status != '1') return false
|
||||
if (used.has(row.id)) return false
|
||||
if (!kw) return true
|
||||
return (row.projectName || '').toLowerCase().includes(kw)
|
||||
})
|
||||
})
|
||||
|
||||
function parseList(res: unknown) {
|
||||
return Array.isArray(res) ? res : (res as any)?.list || []
|
||||
}
|
||||
|
||||
async function loadPackages() {
|
||||
if (!props.institutionId) return
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await fetchCheckupInstitutionPackages(props.institutionId)
|
||||
tableData.value = parseList(res)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function resetForm() {
|
||||
formData.packageName = ''
|
||||
formData.packageCode = ''
|
||||
formData.status = '1'
|
||||
formData.remark = ''
|
||||
detailItems.value = []
|
||||
editingId.value = null
|
||||
}
|
||||
|
||||
function handleAdd() {
|
||||
isEdit.value = false
|
||||
dialogTitle.value = '新增套餐'
|
||||
resetForm()
|
||||
dialogVisible.value = true
|
||||
formRef.value?.clearValidate?.()
|
||||
}
|
||||
|
||||
async function handleEdit(row: any) {
|
||||
isEdit.value = true
|
||||
dialogTitle.value = '编辑套餐'
|
||||
editingId.value = row.id
|
||||
dialogVisible.value = true
|
||||
try {
|
||||
const detail = await fetchCheckupInstitutionPackageDetail(row.id)
|
||||
const d = (detail as any)?.data ?? detail
|
||||
formData.packageName = d.packageName || ''
|
||||
formData.packageCode = d.packageCode || ''
|
||||
formData.status = d.status != null ? String(d.status) : '1'
|
||||
formData.remark = d.remark || ''
|
||||
detailItems.value = (d.items || []).map((it: any) => ({
|
||||
checkupInstitutionProjectId: it.checkupInstitutionProjectId,
|
||||
projectName: it.projectName,
|
||||
projectFee: it.projectFee ?? 0,
|
||||
status: it.status != null ? String(it.status) : '1',
|
||||
remark: it.remark || '',
|
||||
sourceProjectDeleted: !!it.sourceProjectDeleted
|
||||
}))
|
||||
} catch {
|
||||
detailItems.value = []
|
||||
}
|
||||
formRef.value?.clearValidate?.()
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
const valid = await formRef.value?.validate?.().catch(() => false)
|
||||
if (!valid) return
|
||||
if (detailItems.value.length === 0) {
|
||||
ElMessage.warning('请至少添加一个体检项目')
|
||||
return
|
||||
}
|
||||
submitLoading.value = true
|
||||
try {
|
||||
const payload = {
|
||||
packageName: formData.packageName.trim(),
|
||||
packageCode: formData.packageCode.trim(),
|
||||
status: formData.status,
|
||||
remark: formData.remark?.trim() || undefined,
|
||||
items: detailItems.value.map((row, idx) => ({
|
||||
checkupInstitutionProjectId: row.checkupInstitutionProjectId,
|
||||
projectName: row.projectName,
|
||||
projectFee: row.projectFee,
|
||||
remark: row.remark?.trim() || undefined,
|
||||
orderNum: idx + 1
|
||||
}))
|
||||
}
|
||||
if (isEdit.value && editingId.value) {
|
||||
await fetchUpdateCheckupInstitutionPackage(editingId.value, payload)
|
||||
ElMessage.success('已保存')
|
||||
} else {
|
||||
await fetchCreateCheckupInstitutionPackage(props.institutionId, payload)
|
||||
ElMessage.success('已新增')
|
||||
}
|
||||
dialogVisible.value = false
|
||||
await loadPackages()
|
||||
} finally {
|
||||
submitLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleDelete(row: any) {
|
||||
await ElMessageBox.confirm(`确定删除套餐「${row.packageName}」?`, '提示', { type: 'warning' })
|
||||
await fetchDeleteCheckupInstitutionPackage(row.id)
|
||||
ElMessage.success('已删除')
|
||||
await loadPackages()
|
||||
}
|
||||
|
||||
async function openProjectSelector() {
|
||||
projectSelectorKeyword.value = ''
|
||||
projectSelectorSelected.value = []
|
||||
projectSelectorVisible.value = true
|
||||
try {
|
||||
const res = await fetchCheckupInstitutionProjects(props.institutionId)
|
||||
projectSelectorList.value = parseList(res)
|
||||
} catch {
|
||||
projectSelectorList.value = []
|
||||
}
|
||||
}
|
||||
|
||||
function confirmProjectSelector() {
|
||||
for (const row of projectSelectorSelected.value) {
|
||||
detailItems.value.push({
|
||||
checkupInstitutionProjectId: row.id,
|
||||
projectName: row.projectName || '',
|
||||
projectFee: row.projectFee ?? 0,
|
||||
status: row.status != null ? String(row.status) : '1',
|
||||
remark: row.remark || '',
|
||||
sourceProjectDeleted: false
|
||||
})
|
||||
}
|
||||
projectSelectorVisible.value = false
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.institutionId,
|
||||
(id) => {
|
||||
if (id) loadPackages()
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.package-panel {
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
.package-dialog-form {
|
||||
:deep(.el-form-item) {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.detail-section {
|
||||
margin-top: 16px;
|
||||
|
||||
.detail-section-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.detail-section-title {
|
||||
margin: 0;
|
||||
padding-left: 10px;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: #1e293b;
|
||||
border-left: 3px solid #10b981;
|
||||
line-height: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.package-total {
|
||||
margin-top: 12px;
|
||||
text-align: right;
|
||||
font-size: 14px;
|
||||
color: var(--mint-text-muted);
|
||||
|
||||
strong {
|
||||
color: #059669;
|
||||
font-size: 16px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,761 @@
|
||||
<!-- 体检机构 — 项目价格配置 -->
|
||||
<!-- eslint-disable vue/no-v-model-argument -->
|
||||
<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 />
|
||||
</el-form-item>
|
||||
<el-form-item label="状态">
|
||||
<el-select v-model="searchForm.tag" placeholder="全部" clearable style="width: 100%">
|
||||
<el-option label="正常" value="1" />
|
||||
<el-option label="停用" value="0" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div class="filter-actions-row">
|
||||
<div class="filter-actions-end">
|
||||
<el-button class="btn-ghost" @click="handleReset">
|
||||
<el-icon><RefreshLeft /></el-icon>重置
|
||||
</el-button>
|
||||
<el-button class="btn-main" type="primary" @click="handleSearch">
|
||||
<el-icon><Search /></el-icon>搜索
|
||||
</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>
|
||||
</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"
|
||||
@row-dblclick="handleView"
|
||||
>
|
||||
<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="(i) => (pagination.page - 1) * pagination.pageSize + i + 1"
|
||||
/>
|
||||
<el-table-column prop="institutionName" label="机构名称" min-width="160" align="center" header-align="center" />
|
||||
<el-table-column prop="institutionAddress" label="机构地址" min-width="180" align="center" header-align="center" />
|
||||
<el-table-column prop="contactName" label="联系人" min-width="100" align="center" header-align="center" />
|
||||
<el-table-column prop="contactPhone" label="联系电话" min-width="120" align="center" header-align="center" />
|
||||
<el-table-column prop="tag" label="状态" width="90" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<span :class="['tag', row.status == '1' ? 'success' : 'muted']">
|
||||
{{ row.status == '1' ? '正常' : '停用' }}
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="400" fixed="right" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button class="btn-op-item" @click="handleView(row)"><el-icon><View /></el-icon>查看</el-button>
|
||||
<el-button class="btn-op-item primary" @click="openItemDialog(row)"><el-icon><Setting /></el-icon>项目价格配置</el-button>
|
||||
<el-button class="btn-op-item" @click="handleEdit(row)"><el-icon><Edit /></el-icon>编辑</el-button>
|
||||
<el-button class="btn-op-item" @click="handleDelete(row)"><el-icon><Delete /></el-icon>删除</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="(v) => ((pagination.page = 1), (pagination.pageSize = v), loadData())"
|
||||
@current-change="(v) => ((pagination.page = v), loadData())"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 新增/编辑机构弹窗 -->
|
||||
<el-dialog
|
||||
v-model="companyDialogVisible"
|
||||
:title="companyDialogTitle"
|
||||
width="720px"
|
||||
class="dialog-form-layout"
|
||||
align-center
|
||||
destroy-on-close
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<el-form ref="companyFormRef" :model="companyForm" :rules="companyFormRules" label-position="top" class="biz-dialog-form">
|
||||
<div class="form-grid-2">
|
||||
<el-form-item label="机构名称" prop="institutionName">
|
||||
<el-input v-model="companyForm.institutionName" placeholder="请输入机构名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="机构地址">
|
||||
<el-input v-model="companyForm.institutionAddress" placeholder="请输入机构地址" />
|
||||
</el-form-item>
|
||||
<el-form-item label="联系人">
|
||||
<el-input v-model="companyForm.contactName" placeholder="请输入联系人" />
|
||||
</el-form-item>
|
||||
<el-form-item label="联系电话">
|
||||
<el-input v-model="companyForm.contactPhone" placeholder="请输入联系电话" />
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="tag">
|
||||
<el-radio-group v-model="companyForm.tag">
|
||||
<el-radio :value="1">正常</el-radio>
|
||||
<el-radio :value="0">停用</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" class="form-col-span-2">
|
||||
<el-input v-model="companyForm.remark" type="textarea" :rows="2" />
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div class="form-section">
|
||||
<div class="section-title">开票信息</div>
|
||||
<div class="form-grid-2">
|
||||
<el-form-item label="发票抬头">
|
||||
<el-input v-model="companyForm.invoiceTitle" placeholder="与营业执照一致" />
|
||||
</el-form-item>
|
||||
<el-form-item label="纳税人识别号">
|
||||
<el-input v-model="companyForm.taxNo" placeholder="统一社会信用代码" />
|
||||
</el-form-item>
|
||||
<el-form-item label="开户银行">
|
||||
<el-input v-model="companyForm.bankName" placeholder="收款银行全称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="银行账号">
|
||||
<el-input v-model="companyForm.bankAccount" placeholder="收款账号" />
|
||||
</el-form-item>
|
||||
</div>
|
||||
</div>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button class="btn-ghost" @click="companyDialogVisible = false">
|
||||
<el-icon><Close /></el-icon>取消
|
||||
</el-button>
|
||||
<el-button class="btn-main" type="primary" :loading="companySubmitLoading" @click="submitCompany">
|
||||
<el-icon><Check /></el-icon>确定
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 项目价格配置弹窗 -->
|
||||
<el-dialog
|
||||
v-model="itemDialogVisible"
|
||||
:title="itemDialogTitle"
|
||||
width="1120px"
|
||||
class="dialog-form-layout checkup-item-config-dialog"
|
||||
align-center
|
||||
destroy-on-close
|
||||
:close-on-click-modal="false"
|
||||
@closed="onItemDialogClosed"
|
||||
>
|
||||
<div class="item-dialog-head">
|
||||
<span class="muted">当前机构:{{ currentInstitutionName }}</span>
|
||||
</div>
|
||||
<el-tabs v-model="itemConfigTab" class="item-config-tabs">
|
||||
<el-tab-pane label="项目列表" name="projects">
|
||||
<div class="list-toolbar item-toolbar">
|
||||
<div class="list-toolbar-row">
|
||||
<div class="list-toolbar-selected">
|
||||
已选 <span class="sel-num">{{ itemSelected.length }}</span> 项
|
||||
</div>
|
||||
<el-button class="btn-main" type="primary" @click="handleAddItem">
|
||||
<el-icon><Plus /></el-icon>新增项目
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="list-body list-wrap item-table-wrap">
|
||||
<el-table
|
||||
class="list-table"
|
||||
:data="itemTable"
|
||||
v-loading="itemLoading"
|
||||
stripe
|
||||
row-key="id"
|
||||
max-height="460"
|
||||
@selection-change="onItemSelectionChange"
|
||||
>
|
||||
<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" />
|
||||
<el-table-column prop="projectName" label="项目名称" min-width="160" align="center" header-align="center" />
|
||||
<el-table-column prop="projectFee" label="项目费用(元)" width="120" align="center" header-align="center">
|
||||
<template #default="{ row }">{{ row.projectFee != null ? `¥${row.projectFee}` : '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="status" label="状态" width="90" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<span :class="['tag', row.status == '1' ? 'success' : 'muted']">
|
||||
{{ row.status == '1' ? '正常' : '停用' }}
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="remark" label="备注" min-width="140" align="center" header-align="center" show-overflow-tooltip />
|
||||
<el-table-column label="操作" width="260" fixed="right" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button class="btn-op-item primary" @click="handleEditItem(row)"><el-icon><Edit /></el-icon>编辑</el-button>
|
||||
<el-button class="btn-op-item" @click="handleDeleteItem(row)"><el-icon><Delete /></el-icon>删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div class="pagination list-pager-bar">
|
||||
<el-pagination
|
||||
:current-page="itemPagination.page"
|
||||
:page-size="itemPagination.pageSize"
|
||||
:total="itemPagination.total"
|
||||
:page-sizes="[10, 20, 50]"
|
||||
layout="total, sizes, prev, pager, next"
|
||||
@size-change="(v) => ((itemPagination.page = 1), (itemPagination.pageSize = v), loadItems())"
|
||||
@current-change="(v) => ((itemPagination.page = v), loadItems())"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="套餐管理" name="packages">
|
||||
<CheckupPackagePanel
|
||||
v-if="itemConfigTab === 'packages' && currentInstitutionId"
|
||||
:institution-id="currentInstitutionId"
|
||||
:institution-name="currentInstitutionName"
|
||||
/>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
|
||||
<!-- 新增/编辑项目嵌套弹窗 -->
|
||||
<el-dialog
|
||||
v-model="itemFormVisible"
|
||||
:title="itemFormTitle"
|
||||
width="640px"
|
||||
class="dialog-form-layout"
|
||||
align-center
|
||||
append-to-body
|
||||
destroy-on-close
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<el-form ref="itemFormRef" :model="itemForm" :rules="itemFormRules" label-position="top" class="biz-dialog-form">
|
||||
<div class="form-grid-2">
|
||||
<el-form-item label="项目名称" prop="projectName">
|
||||
<el-input v-model="itemForm.projectName" />
|
||||
</el-form-item>
|
||||
<el-form-item label="项目费用(元)" prop="projectFee">
|
||||
<el-input-number v-model="itemForm.projectFee" :min="0" :precision="2" style="width: 100%" />
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-radio-group v-model="itemForm.status">
|
||||
<el-radio value="1">正常</el-radio>
|
||||
<el-radio value="0">停用</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" class="form-col-span-2">
|
||||
<el-input v-model="itemForm.remark" type="textarea" :rows="2" />
|
||||
</el-form-item>
|
||||
</div>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button class="btn-ghost" @click="itemFormVisible = false">
|
||||
<el-icon><Close /></el-icon>取消
|
||||
</el-button>
|
||||
<el-button class="btn-main" type="primary" :loading="itemSubmitLoading" @click="submitItem">
|
||||
<el-icon><Check /></el-icon>确定
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
<template #footer>
|
||||
<el-button class="btn-ghost" @click="itemDialogVisible = false">
|
||||
<el-icon><Close /></el-icon>关闭
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 查看弹窗 -->
|
||||
<SystemViewDialog
|
||||
v-model:visible="viewVisible"
|
||||
title="查看机构"
|
||||
:icon="OfficeBuilding"
|
||||
:meta="viewInstitutionName"
|
||||
:sections="viewSections"
|
||||
/>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import {
|
||||
Plus,
|
||||
Close,
|
||||
Check,
|
||||
Search,
|
||||
RefreshLeft,
|
||||
View,
|
||||
Setting,
|
||||
Edit,
|
||||
Delete,
|
||||
OfficeBuilding
|
||||
} from '@element-plus/icons-vue'
|
||||
import SystemViewDialog from '@/components/business/system-view-dialog/index.vue'
|
||||
import CheckupPackagePanel from './CheckupPackagePanel.vue'
|
||||
import type { ViewSection } from '@/components/business/system-view-dialog/index.vue'
|
||||
import {
|
||||
fetchCheckupInstitutionList,
|
||||
fetchCreateCheckupInstitution,
|
||||
fetchUpdateCheckupInstitution,
|
||||
fetchDeleteCheckupInstitution,
|
||||
fetchCheckupInstitutionInvoices,
|
||||
fetchCreateCheckupInstitutionInvoice,
|
||||
fetchUpdateCheckupInstitutionInvoice,
|
||||
fetchDeleteCheckupInstitutionInvoice,
|
||||
fetchCheckupInstitutionProjects,
|
||||
fetchCreateCheckupInstitutionProject,
|
||||
fetchUpdateCheckupInstitutionProject,
|
||||
fetchDeleteCheckupInstitutionProject
|
||||
} from '@/api/admin'
|
||||
|
||||
defineOptions({ name: 'PilotCheckupInstitution' })
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// 搜索 & 主表
|
||||
// ---------------------------------------------------------------------------
|
||||
const searchForm = reactive({ keyword: '', tag: '' })
|
||||
const tableData = ref<any[]>([])
|
||||
const selectedRows = ref<any[]>([])
|
||||
const loading = ref(false)
|
||||
const pagination = reactive({ page: 1, pageSize: 10, total: 0 })
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// 机构弹窗
|
||||
// ---------------------------------------------------------------------------
|
||||
const companyDialogVisible = ref(false)
|
||||
const companyDialogTitle = ref('新增机构')
|
||||
const companyIsEdit = ref(false)
|
||||
const companySubmitLoading = ref(false)
|
||||
const companyFormRef = ref()
|
||||
const editingId = ref<string | null>(null)
|
||||
const companyForm = reactive({
|
||||
institutionName: '',
|
||||
institutionAddress: '',
|
||||
contactName: '',
|
||||
contactPhone: '',
|
||||
invoiceTitle: '',
|
||||
taxNo: '',
|
||||
bankName: '',
|
||||
bankAccount: '',
|
||||
tag: 1 as number,
|
||||
remark: ''
|
||||
})
|
||||
const companyFormRules = {
|
||||
institutionName: [{ required: true, message: '请输入机构名称', trigger: 'blur' }],
|
||||
tag: [{ required: true, message: '请选择状态', trigger: 'change' }]
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// 项目价格配置弹窗
|
||||
// ---------------------------------------------------------------------------
|
||||
const itemDialogVisible = ref(false)
|
||||
const itemDialogTitle = ref('项目价格配置')
|
||||
const itemConfigTab = ref<'projects' | 'packages'>('projects')
|
||||
const currentInstitutionId = ref('')
|
||||
const currentInstitutionName = ref('')
|
||||
const itemTable = ref<any[]>([])
|
||||
const itemSelected = ref<any[]>([])
|
||||
const itemLoading = ref(false)
|
||||
const itemPagination = reactive({ page: 1, pageSize: 10, total: 0 })
|
||||
|
||||
const itemFormVisible = ref(false)
|
||||
const itemFormTitle = ref('新增项目')
|
||||
const itemIsEdit = ref(false)
|
||||
const itemSubmitLoading = ref(false)
|
||||
const itemFormRef = ref()
|
||||
const editingItemId = ref<string | null>(null)
|
||||
const itemForm = reactive({
|
||||
projectName: '',
|
||||
projectFee: 0 as number | null,
|
||||
status: '1',
|
||||
remark: ''
|
||||
})
|
||||
const itemFormRules = {
|
||||
projectName: [{ required: true, message: '请输入项目名称', trigger: 'blur' }],
|
||||
status: [{ required: true, message: '请选择状态', trigger: 'change' }]
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// 查看弹窗
|
||||
// ---------------------------------------------------------------------------
|
||||
const viewVisible = ref(false)
|
||||
const viewInstitutionName = ref('')
|
||||
const viewSections = ref<ViewSection[]>([])
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// 主表数据加载
|
||||
// ---------------------------------------------------------------------------
|
||||
async function loadData() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await fetchCheckupInstitutionList({
|
||||
page: pagination.page,
|
||||
pageSize: pagination.pageSize,
|
||||
keyword: searchForm.keyword || undefined,
|
||||
tag: searchForm.tag ? Number(searchForm.tag) : undefined, // 后端 list 接口暂无 tag/status 过滤参数
|
||||
})
|
||||
tableData.value = (res as any)?.list || []
|
||||
pagination.total = (res as any)?.total ?? 0
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function handleSearch() {
|
||||
pagination.page = 1
|
||||
loadData()
|
||||
}
|
||||
|
||||
function handleReset() {
|
||||
searchForm.keyword = ''
|
||||
searchForm.tag = ''
|
||||
pagination.page = 1
|
||||
loadData()
|
||||
}
|
||||
|
||||
function handleSelectionChange(rows: any[]) {
|
||||
selectedRows.value = rows
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// 机构弹窗操作
|
||||
// ---------------------------------------------------------------------------
|
||||
function resetCompanyForm() {
|
||||
companyForm.institutionName = ''
|
||||
companyForm.institutionAddress = ''
|
||||
companyForm.contactName = ''
|
||||
companyForm.contactPhone = ''
|
||||
companyForm.invoiceTitle = ''
|
||||
companyForm.taxNo = ''
|
||||
companyForm.bankName = ''
|
||||
companyForm.bankAccount = ''
|
||||
companyForm.tag = 1
|
||||
companyForm.remark = ''
|
||||
editingId.value = null
|
||||
}
|
||||
|
||||
function handleAdd() {
|
||||
companyIsEdit.value = false
|
||||
companyDialogTitle.value = '新增机构'
|
||||
resetCompanyForm()
|
||||
companyDialogVisible.value = true
|
||||
}
|
||||
|
||||
async function handleEdit(row: any) {
|
||||
companyIsEdit.value = true
|
||||
companyDialogTitle.value = '编辑机构'
|
||||
editingId.value = row.id
|
||||
companyForm.institutionName = row.institutionName || ''
|
||||
companyForm.institutionAddress = row.institutionAddress || ''
|
||||
companyForm.contactName = row.contactName || ''
|
||||
companyForm.contactPhone = row.contactPhone || ''
|
||||
companyForm.tag = row.status != null ? Number(row.status) : 1
|
||||
companyForm.remark = row.remark || ''
|
||||
// 加载开票信息
|
||||
try {
|
||||
const invRes = await fetchCheckupInstitutionInvoices(row.id)
|
||||
const invoices = (invRes as any)?.list || (invRes as any) || []
|
||||
if (invoices.length > 0) {
|
||||
const inv = invoices[0]
|
||||
companyForm.invoiceTitle = inv.invoiceTitle || inv.companyName || ''
|
||||
companyForm.taxNo = inv.taxNo || ''
|
||||
companyForm.bankName = inv.bankName || ''
|
||||
companyForm.bankAccount = inv.bankAccount || ''
|
||||
} else {
|
||||
companyForm.invoiceTitle = ''
|
||||
companyForm.taxNo = ''
|
||||
companyForm.bankName = ''
|
||||
companyForm.bankAccount = ''
|
||||
}
|
||||
} catch {
|
||||
companyForm.invoiceTitle = ''
|
||||
companyForm.taxNo = ''
|
||||
companyForm.bankName = ''
|
||||
companyForm.bankAccount = ''
|
||||
}
|
||||
companyDialogVisible.value = true
|
||||
}
|
||||
|
||||
async function submitCompany() {
|
||||
const valid = await companyFormRef.value?.validate?.().catch(() => false)
|
||||
if (!valid) return
|
||||
companySubmitLoading.value = true
|
||||
try {
|
||||
const payload = {
|
||||
institutionName: companyForm.institutionName.trim(),
|
||||
institutionAddress: companyForm.institutionAddress?.trim() || undefined,
|
||||
contactName: companyForm.contactName?.trim() || undefined,
|
||||
contactPhone: companyForm.contactPhone?.trim() || undefined,
|
||||
status: String(companyForm.tag),
|
||||
remark: companyForm.remark?.trim() || undefined
|
||||
}
|
||||
if (companyIsEdit.value && editingId.value) {
|
||||
await fetchUpdateCheckupInstitution(editingId.value, payload)
|
||||
// 同步开票信息
|
||||
const invRes = await fetchCheckupInstitutionInvoices(editingId.value)
|
||||
const invoices = (invRes as any)?.list || (invRes as any) || []
|
||||
const invoicePayload = {
|
||||
companyName: companyForm.invoiceTitle?.trim() || undefined,
|
||||
invoiceTitle: companyForm.invoiceTitle?.trim() || undefined,
|
||||
taxNo: companyForm.taxNo?.trim() || undefined,
|
||||
bankName: companyForm.bankName?.trim() || undefined,
|
||||
bankAccount: companyForm.bankAccount?.trim() || undefined
|
||||
}
|
||||
if (invoices.length > 0) {
|
||||
await fetchUpdateCheckupInstitutionInvoice(invoices[0].id, invoicePayload)
|
||||
} else if (companyForm.invoiceTitle) {
|
||||
await fetchCreateCheckupInstitutionInvoice(editingId.value, invoicePayload)
|
||||
}
|
||||
ElMessage.success('已保存')
|
||||
} else {
|
||||
const newInst = await fetchCreateCheckupInstitution(payload)
|
||||
// 新增时同步创建开票信息
|
||||
if ((newInst as any)?.id && companyForm.invoiceTitle?.trim()) {
|
||||
const invoicePayload = {
|
||||
companyName: companyForm.invoiceTitle?.trim() || undefined,
|
||||
invoiceTitle: companyForm.invoiceTitle?.trim() || undefined,
|
||||
taxNo: companyForm.taxNo?.trim() || undefined,
|
||||
bankName: companyForm.bankName?.trim() || undefined,
|
||||
bankAccount: companyForm.bankAccount?.trim() || undefined,
|
||||
}
|
||||
await fetchCreateCheckupInstitutionInvoice((newInst as any).id, invoicePayload)
|
||||
}
|
||||
ElMessage.success('已新增')
|
||||
}
|
||||
companyDialogVisible.value = false
|
||||
loadData()
|
||||
} finally {
|
||||
companySubmitLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleDelete(row: any) {
|
||||
await ElMessageBox.confirm(`确定删除「${row.institutionName}」?其下属项目价格将一并删除。`, '提示', {
|
||||
type: 'warning'
|
||||
})
|
||||
await fetchDeleteCheckupInstitution(row.id)
|
||||
ElMessage.success('已删除')
|
||||
loadData()
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// 查看弹窗
|
||||
// ---------------------------------------------------------------------------
|
||||
async function handleView(row: any) {
|
||||
viewInstitutionName.value = row.institutionName || ''
|
||||
const sections: ViewSection[] = [
|
||||
{
|
||||
title: '基本信息',
|
||||
fields: [
|
||||
{ label: '机构名称', value: row.institutionName },
|
||||
{ label: '机构地址', value: row.institutionAddress, span: true },
|
||||
{ label: '联系人', value: row.contactName },
|
||||
{ label: '联系电话', value: row.contactPhone },
|
||||
{ label: '状态', value: row.status == '1' ? '正常' : '停用' },
|
||||
{ label: '备注', value: row.remark, span: true }
|
||||
]
|
||||
}
|
||||
]
|
||||
// 加载开票信息
|
||||
try {
|
||||
const invRes = await fetchCheckupInstitutionInvoices(row.id)
|
||||
const invoices = (invRes as any)?.list || (invRes as any) || []
|
||||
if (invoices.length > 0) {
|
||||
const inv = invoices[0]
|
||||
sections.push({
|
||||
title: '开票信息',
|
||||
fields: [
|
||||
{ label: '发票抬头', value: inv.invoiceTitle || inv.companyName },
|
||||
{ label: '纳税人识别号', value: inv.taxNo },
|
||||
{ label: '开户银行', value: inv.bankName },
|
||||
{ label: '银行账号', value: inv.bankAccount }
|
||||
]
|
||||
})
|
||||
}
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
viewSections.value = sections
|
||||
viewVisible.value = true
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// 项目价格配置弹窗
|
||||
// ---------------------------------------------------------------------------
|
||||
function openItemDialog(row: any, tab: 'projects' | 'packages' = 'projects') {
|
||||
currentInstitutionId.value = row.id
|
||||
currentInstitutionName.value = row.institutionName || ''
|
||||
itemPagination.page = 1
|
||||
itemSelected.value = []
|
||||
itemConfigTab.value = tab
|
||||
itemDialogTitle.value = `项目价格配置 — ${row.institutionName}`
|
||||
itemDialogVisible.value = true
|
||||
loadItems()
|
||||
}
|
||||
|
||||
async function loadItems() {
|
||||
if (!currentInstitutionId.value) return
|
||||
itemLoading.value = true
|
||||
try {
|
||||
const res = await fetchCheckupInstitutionProjects(currentInstitutionId.value)
|
||||
const list = Array.isArray(res) ? res : (res as any)?.list || []
|
||||
itemTable.value = list
|
||||
itemPagination.total = Array.isArray(res) ? list.length : ((res as any)?.total ?? list.length)
|
||||
} finally {
|
||||
itemLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function onItemDialogClosed() {
|
||||
currentInstitutionId.value = ''
|
||||
currentInstitutionName.value = ''
|
||||
itemTable.value = []
|
||||
}
|
||||
|
||||
function onItemSelectionChange(rows: any[]) {
|
||||
itemSelected.value = rows
|
||||
}
|
||||
|
||||
function resetItemForm() {
|
||||
itemForm.projectName = ''
|
||||
itemForm.projectFee = 0
|
||||
itemForm.status = '1'
|
||||
itemForm.remark = ''
|
||||
editingItemId.value = null
|
||||
}
|
||||
|
||||
function handleAddItem() {
|
||||
itemIsEdit.value = false
|
||||
itemFormTitle.value = '新增项目'
|
||||
resetItemForm()
|
||||
itemFormVisible.value = true
|
||||
}
|
||||
|
||||
function handleEditItem(row: any) {
|
||||
itemIsEdit.value = true
|
||||
itemFormTitle.value = '编辑项目'
|
||||
editingItemId.value = row.id
|
||||
itemForm.projectName = row.projectName || ''
|
||||
itemForm.projectFee = row.projectFee ?? 0
|
||||
itemForm.status = row.status != null ? String(row.status) : '1'
|
||||
itemForm.remark = row.remark || ''
|
||||
itemFormVisible.value = true
|
||||
}
|
||||
|
||||
async function submitItem() {
|
||||
const valid = await itemFormRef.value?.validate?.().catch(() => false)
|
||||
if (!valid) return
|
||||
itemSubmitLoading.value = true
|
||||
try {
|
||||
const payload = {
|
||||
projectName: itemForm.projectName.trim(),
|
||||
projectFee: itemForm.projectFee,
|
||||
status: itemForm.status,
|
||||
remark: itemForm.remark?.trim() || undefined
|
||||
}
|
||||
if (itemIsEdit.value && editingItemId.value) {
|
||||
await fetchUpdateCheckupInstitutionProject(editingItemId.value, payload)
|
||||
ElMessage.success('已保存')
|
||||
} else {
|
||||
await fetchCreateCheckupInstitutionProject(currentInstitutionId.value, payload)
|
||||
ElMessage.success('已新增')
|
||||
}
|
||||
itemFormVisible.value = false
|
||||
loadItems()
|
||||
} finally {
|
||||
itemSubmitLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleDeleteItem(row: any) {
|
||||
await ElMessageBox.confirm(`确定删除「${row.projectName}」?`, '提示', { type: 'warning' })
|
||||
await fetchDeleteCheckupInstitutionProject(row.id)
|
||||
ElMessage.success('已删除')
|
||||
loadItems()
|
||||
}
|
||||
|
||||
onMounted(() => loadData())
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.biz-dialog-form {
|
||||
:deep(.el-form-item) {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.item-dialog-head {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.item-dialog-head .muted {
|
||||
font-size: 13px;
|
||||
color: var(--mint-text-muted);
|
||||
}
|
||||
|
||||
.item-config-tabs {
|
||||
margin-top: 4px;
|
||||
|
||||
:deep(.el-tabs__content) {
|
||||
min-height: 480px;
|
||||
}
|
||||
}
|
||||
|
||||
.item-toolbar {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.item-table-wrap {
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
.form-section {
|
||||
background: #fafafa;
|
||||
border-radius: 8px;
|
||||
padding: 20px;
|
||||
margin: 4px 0;
|
||||
}
|
||||
|
||||
.form-section .section-title {
|
||||
font-size: 15px;
|
||||
font-weight: 500;
|
||||
color: #303133;
|
||||
margin-bottom: 16px;
|
||||
padding-bottom: 12px;
|
||||
padding-left: 10px;
|
||||
border-bottom: 1px solid #ebeef5;
|
||||
border-left: 3px solid #10b981;
|
||||
}
|
||||
</style>
|
||||
|
||||
<!-- 弹窗 teleport 到 body,高度类名需非 scoped -->
|
||||
<style lang="scss">
|
||||
.el-dialog.checkup-item-config-dialog.dialog-form-layout {
|
||||
min-height: min(720px, calc(100vh - 80px));
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,653 @@
|
||||
<!-- 细胞产品项目价格管理(主子表) -->
|
||||
<!-- eslint-disable vue/no-v-model-argument -->
|
||||
<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 />
|
||||
</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"
|
||||
@row-dblclick="handleView"
|
||||
>
|
||||
<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="systemName"
|
||||
label="体系名称"
|
||||
min-width="140"
|
||||
align="center"
|
||||
header-align="center"
|
||||
/>
|
||||
<el-table-column
|
||||
prop="systemCode"
|
||||
label="体系编码"
|
||||
min-width="120"
|
||||
align="center"
|
||||
header-align="center"
|
||||
/>
|
||||
<el-table-column prop="status" label="状态" min-width="80" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="String(row.status) === '1' ? 'success' : 'danger'" size="small">
|
||||
{{ String(row.status) === '1' ? '正常' : '停用' }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="remark" label="备注" min-width="150" align="center" header-align="center" />
|
||||
<el-table-column
|
||||
prop="createTime"
|
||||
label="创建时间"
|
||||
min-width="180"
|
||||
align="center"
|
||||
header-align="center"
|
||||
/>
|
||||
<el-table-column label="操作" width="320" fixed="right" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button class="btn-op-item" @click="handleView(row)"
|
||||
><el-icon><View /></el-icon>查看</el-button
|
||||
>
|
||||
<el-button class="btn-op-item primary" @click="handleEdit(row)"
|
||||
><el-icon><Edit /></el-icon>编辑</el-button
|
||||
>
|
||||
<el-button class="btn-op-item" @click="handleDelete(row)"
|
||||
><el-icon><Delete /></el-icon>删除</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="1100px"
|
||||
class="dialog-form-layout"
|
||||
align-center
|
||||
destroy-on-close
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
label-position="top"
|
||||
class="system-dialog-form"
|
||||
scroll-to-error
|
||||
:scroll-into-view-options="{ behavior: 'smooth', block: 'center' }"
|
||||
>
|
||||
<div class="form-grid-2">
|
||||
<el-form-item label="体系名称" prop="systemName">
|
||||
<el-input v-model="formData.systemName" placeholder="请输入体系名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="体系编码" prop="systemCode">
|
||||
<el-input v-model="formData.systemCode" placeholder="请输入体系编码" />
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-select v-model="formData.status" placeholder="请选择状态" style="width: 100%">
|
||||
<el-option label="正常" value="1" />
|
||||
<el-option label="停用" value="0" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注">
|
||||
<el-input v-model="formData.remark" placeholder="可选" />
|
||||
</el-form-item>
|
||||
</div>
|
||||
</el-form>
|
||||
|
||||
<!-- 价格明细 — 子表 -->
|
||||
<div class="detail-section">
|
||||
<div class="detail-section-head">
|
||||
<h3 class="detail-section-title">价格明细</h3>
|
||||
<el-button class="btn-main" type="primary" size="small" @click="handleOpenPriceSelector">
|
||||
<el-icon><Plus /></el-icon>
|
||||
从价格体系添加
|
||||
</el-button>
|
||||
</div>
|
||||
<el-table :data="detailItems" size="small" class="detail-table" max-height="320">
|
||||
<el-table-column type="index" label="序号" width="55" align="center" header-align="center" />
|
||||
<el-table-column prop="projectName" label="项目名称" min-width="120" align="center" header-align="center" />
|
||||
<el-table-column prop="projectCode" label="项目编码" min-width="100" align="center" header-align="center" />
|
||||
<el-table-column prop="cellTypeName" label="细胞类型" min-width="100" align="center" header-align="center" />
|
||||
<el-table-column prop="specText" label="规格" min-width="100" align="center" header-align="center" />
|
||||
<el-table-column label="单价(元)" min-width="100" align="center" header-align="center">
|
||||
<template #default="{ row, $index }">
|
||||
<el-input-number
|
||||
v-model="row.unitPrice"
|
||||
:precision="2"
|
||||
:min="0"
|
||||
:controls="false"
|
||||
size="default"
|
||||
style="width: 100%"
|
||||
placeholder="请输入单价"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="260" fixed="right" align="center" header-align="center">
|
||||
<template #default="{ $index }">
|
||||
<el-button class="btn-op-item" type="danger" link size="small" @click="detailItems.splice($index, 1)">
|
||||
<el-icon><Delete /></el-icon>删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
<template #footer>
|
||||
<el-button class="btn-ghost" @click="dialogVisible = false">
|
||||
<el-icon><Close /></el-icon>
|
||||
取消
|
||||
</el-button>
|
||||
<el-button class="btn-main" type="primary" @click="handleSubmit" :loading="submitLoading">
|
||||
<el-icon><Check /></el-icon>
|
||||
确定
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 从价格体系添加 — 子弹窗 -->
|
||||
<el-dialog
|
||||
v-model="priceSelectorVisible"
|
||||
title="从价格体系添加"
|
||||
width="860px"
|
||||
class="dialog-form-layout"
|
||||
align-center
|
||||
destroy-on-close
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<div style="margin-bottom: 12px">
|
||||
<el-input
|
||||
v-model="priceSelectorKeyword"
|
||||
placeholder="搜索项目名称/编码"
|
||||
clearable
|
||||
style="width: 260px"
|
||||
/>
|
||||
</div>
|
||||
<el-table
|
||||
ref="priceSelectorTableRef"
|
||||
:data="filteredPriceSelectorList"
|
||||
max-height="400"
|
||||
@selection-change="handlePriceSelectorChange"
|
||||
>
|
||||
<el-table-column type="selection" width="55" align="center" header-align="center" />
|
||||
<el-table-column prop="projectName" label="项目名称" min-width="120" align="center" header-align="center" />
|
||||
<el-table-column prop="projectCode" label="项目编码" min-width="100" align="center" header-align="center" />
|
||||
<el-table-column prop="cellTypeName" label="细胞类型" min-width="100" align="center" header-align="center" />
|
||||
<el-table-column prop="specText" label="规格" min-width="100" align="center" header-align="center" />
|
||||
<el-table-column label="单价" min-width="80" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
{{ row.unitPrice != null ? `${row.unitPrice} 元` : '-' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="remark" label="备注" min-width="120" align="center" header-align="center" />
|
||||
</el-table>
|
||||
<template #footer>
|
||||
<el-button class="btn-ghost" @click="priceSelectorVisible = false">取消</el-button>
|
||||
<el-button
|
||||
class="btn-main"
|
||||
type="primary"
|
||||
:disabled="priceSelectorSelected.length === 0"
|
||||
@click="handleConfirmPriceSelector"
|
||||
>
|
||||
确认添加({{ priceSelectorSelected.length }})
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<SystemViewDialog
|
||||
v-model:visible="viewVisible"
|
||||
:title="viewRow?.systemName || '体系详情'"
|
||||
:icon="ScaleToOriginal"
|
||||
:meta="viewRow?.createTime || ''"
|
||||
:sections="viewSections"
|
||||
/>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted, computed, nextTick } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { Plus, Close, Check, View, Edit, Delete, ScaleToOriginal } from '@element-plus/icons-vue'
|
||||
import SystemViewDialog from '@/components/business/system-view-dialog/index.vue'
|
||||
import { withFullscreenLoading, fullscreenLoadingText } from '@/utils/fullscreen-loading'
|
||||
import {
|
||||
fetchProjectSystemList,
|
||||
fetchCreateProjectSystem,
|
||||
fetchUpdateProjectSystem,
|
||||
fetchDeleteProjectSystem,
|
||||
fetchProjectSystemItems,
|
||||
fetchCreateProjectSystemItem,
|
||||
fetchUpdateProjectSystemItem,
|
||||
fetchDeleteProjectSystemItem,
|
||||
fetchCellProductPriceList
|
||||
} from '@/api/admin'
|
||||
|
||||
defineOptions({ name: 'PilotProjectPriceSystem' })
|
||||
|
||||
// --- Search ---
|
||||
const searchForm = reactive<{ keyword: string }>({ keyword: '' })
|
||||
|
||||
// --- Table ---
|
||||
const tableData = ref<any[]>([])
|
||||
const selectedRows = ref<any[]>([])
|
||||
const loading = ref(false)
|
||||
const pagination = reactive({ page: 1, pageSize: 10, total: 0 })
|
||||
|
||||
// --- Dialog ---
|
||||
const dialogVisible = ref(false)
|
||||
const dialogTitle = ref('新增体系')
|
||||
const isEdit = ref(false)
|
||||
const submitLoading = ref(false)
|
||||
const formRef = ref()
|
||||
const editingId = ref<string | null>(null)
|
||||
|
||||
// --- View ---
|
||||
const viewVisible = ref(false)
|
||||
const viewRow = ref<any>(null)
|
||||
|
||||
// --- Detail items ---
|
||||
const detailItems = ref<any[]>([])
|
||||
|
||||
// --- Price selector ---
|
||||
const priceSelectorVisible = ref(false)
|
||||
const priceSelectorList = ref<any[]>([])
|
||||
const priceSelectorSelected = ref<any[]>([])
|
||||
const priceSelectorTableRef = ref()
|
||||
const priceSelectorKeyword = ref('')
|
||||
|
||||
const filteredPriceSelectorList = computed(() => {
|
||||
const kw = priceSelectorKeyword.value.trim().toLowerCase()
|
||||
if (!kw) return priceSelectorList.value
|
||||
return priceSelectorList.value.filter(
|
||||
(row: any) =>
|
||||
(row.projectName || '').toLowerCase().includes(kw) ||
|
||||
(row.projectCode || '').toLowerCase().includes(kw)
|
||||
)
|
||||
})
|
||||
|
||||
// --- Form data ---
|
||||
const formData = reactive({
|
||||
systemName: '',
|
||||
systemCode: '',
|
||||
status: '1' as string,
|
||||
remark: ''
|
||||
})
|
||||
|
||||
const formRules = {
|
||||
systemName: [{ required: true, message: '请输入体系名称', trigger: 'blur' }],
|
||||
systemCode: [{ required: true, message: '请输入体系编码', trigger: 'blur' }]
|
||||
}
|
||||
|
||||
// --- Selection ---
|
||||
const handleSelectionChange = (rows: any[]) => {
|
||||
selectedRows.value = rows
|
||||
}
|
||||
|
||||
// --- View sections ---
|
||||
const viewSections = computed(() => {
|
||||
if (!viewRow.value) return []
|
||||
const row = viewRow.value
|
||||
const items = viewDetailItems.value
|
||||
return [
|
||||
{
|
||||
title: '基本信息',
|
||||
fields: [
|
||||
{ label: '体系名称', value: row.systemName },
|
||||
{ label: '体系编码', value: row.systemCode },
|
||||
{
|
||||
label: '状态',
|
||||
value: String(row.status) === '1' ? '正常' : '停用'
|
||||
},
|
||||
{ label: '备注', value: row.remark, span: true },
|
||||
{ label: '创建时间', value: row.createTime }
|
||||
]
|
||||
},
|
||||
{
|
||||
title: '价格明细',
|
||||
fields: items.map((item: any, idx: number) => ({
|
||||
label: `明细 ${idx + 1}`,
|
||||
value: `${item.projectName || '-'} / ${item.cellTypeName || '-'} / ${item.specText || '-'} / ${item.unitPrice != null ? item.unitPrice + ' 元' : '-'}`,
|
||||
span: true
|
||||
}))
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
const viewDetailItems = ref<any[]>([])
|
||||
|
||||
// --- Load data ---
|
||||
async function loadData() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await fetchProjectSystemList({
|
||||
page: pagination.page,
|
||||
pageSize: pagination.pageSize,
|
||||
keyword: searchForm.keyword || undefined
|
||||
})
|
||||
tableData.value = (res as any)?.list || []
|
||||
pagination.total = (res as any)?.total ?? 0
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function handleSearch() {
|
||||
pagination.page = 1
|
||||
loadData()
|
||||
}
|
||||
|
||||
function handleReset() {
|
||||
searchForm.keyword = ''
|
||||
pagination.page = 1
|
||||
loadData()
|
||||
}
|
||||
|
||||
// --- Reset form ---
|
||||
function resetForm() {
|
||||
formData.systemName = ''
|
||||
formData.systemCode = ''
|
||||
formData.status = '1'
|
||||
formData.remark = ''
|
||||
editingId.value = null
|
||||
detailItems.value = []
|
||||
}
|
||||
|
||||
// --- Add ---
|
||||
function handleAdd() {
|
||||
isEdit.value = false
|
||||
dialogTitle.value = '新增体系'
|
||||
resetForm()
|
||||
dialogVisible.value = true
|
||||
formRef.value?.clearValidate?.()
|
||||
}
|
||||
|
||||
// --- Edit ---
|
||||
async function handleEdit(row: any) {
|
||||
isEdit.value = true
|
||||
dialogTitle.value = '编辑体系'
|
||||
editingId.value = row.id
|
||||
formData.systemName = row.systemName || ''
|
||||
formData.systemCode = row.systemCode || ''
|
||||
formData.status = row.status != null ? String(row.status) : '1'
|
||||
formData.remark = row.remark || ''
|
||||
dialogVisible.value = true
|
||||
formRef.value?.clearValidate?.()
|
||||
// load existing detail items
|
||||
try {
|
||||
const res = await fetchProjectSystemItems(row.id)
|
||||
detailItems.value = ((res as any)?.list || (res as any) || []).map((item: any) => ({ ...item }))
|
||||
} catch {
|
||||
detailItems.value = []
|
||||
}
|
||||
}
|
||||
|
||||
// --- Submit ---
|
||||
async function handleSubmit() {
|
||||
await formRef.value?.validate?.()
|
||||
submitLoading.value = true
|
||||
try {
|
||||
const masterPayload = {
|
||||
systemName: formData.systemName.trim(),
|
||||
systemCode: formData.systemCode.trim(),
|
||||
status: formData.status,
|
||||
remark: formData.remark?.trim() || undefined
|
||||
}
|
||||
|
||||
let masterId: string
|
||||
|
||||
if (isEdit.value && editingId.value) {
|
||||
await fetchUpdateProjectSystem(editingId.value, masterPayload)
|
||||
masterId = editingId.value
|
||||
} else {
|
||||
const createRes = await fetchCreateProjectSystem(masterPayload)
|
||||
masterId = (createRes as any)?.id || editingId.value!
|
||||
}
|
||||
|
||||
// Handle detail items: for simplicity, delete all existing then re-create
|
||||
if (isEdit.value) {
|
||||
const existingRes = await fetchProjectSystemItems(masterId)
|
||||
const existingItems: any[] = (existingRes as any)?.list || (existingRes as any) || []
|
||||
for (const existing of existingItems) {
|
||||
if (existing.id) {
|
||||
await fetchDeleteProjectSystemItem(existing.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create all current detail items
|
||||
for (const item of detailItems.value) {
|
||||
const itemPayload = {
|
||||
sourcePriceId: item.sourcePriceId || undefined,
|
||||
projectName: item.projectName || undefined,
|
||||
projectCode: item.projectCode || undefined,
|
||||
cellTypeCode: item.cellTypeCode || undefined,
|
||||
cellTypeName: item.cellTypeName || undefined,
|
||||
specText: item.specText || undefined,
|
||||
specId: item.specId || undefined,
|
||||
cellProductTypeId: item.cellProductTypeId || undefined,
|
||||
unitPrice: item.unitPrice ?? undefined
|
||||
}
|
||||
await fetchCreateProjectSystemItem(masterId, itemPayload)
|
||||
}
|
||||
|
||||
ElMessage.success(isEdit.value ? '更新成功' : '创建成功')
|
||||
dialogVisible.value = false
|
||||
await loadData()
|
||||
} catch {
|
||||
/* 校验或接口错误已由全局处理 */
|
||||
} finally {
|
||||
submitLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// --- View ---
|
||||
async function handleView(row: any) {
|
||||
viewRow.value = row
|
||||
try {
|
||||
const res = await fetchProjectSystemItems(row.id)
|
||||
viewDetailItems.value = (res as any)?.list || (res as any) || []
|
||||
} catch {
|
||||
viewDetailItems.value = []
|
||||
}
|
||||
viewVisible.value = true
|
||||
}
|
||||
|
||||
// --- Delete ---
|
||||
async function handleDelete(row: any) {
|
||||
await ElMessageBox.confirm('确定要删除该体系吗?删除后关联的价格明细也将清除。', '提示', { type: 'warning' })
|
||||
await fetchDeleteProjectSystem(row.id)
|
||||
ElMessage.success('删除成功')
|
||||
await loadData()
|
||||
}
|
||||
|
||||
// --- Batch delete ---
|
||||
async function handleBatchDelete() {
|
||||
const ids = selectedRows.value.map((r) => r.id)
|
||||
if (!ids.length) return
|
||||
await ElMessageBox.confirm(`确定删除选中的 ${ids.length} 条记录吗?`, '提示', { type: 'warning' })
|
||||
await withFullscreenLoading(async () => {
|
||||
for (const id of ids) {
|
||||
await fetchDeleteProjectSystem(id)
|
||||
}
|
||||
ElMessage.success('批量删除成功')
|
||||
selectedRows.value = []
|
||||
await loadData()
|
||||
}, fullscreenLoadingText.batchDelete)
|
||||
}
|
||||
|
||||
// --- Price selector ---
|
||||
async function handleOpenPriceSelector() {
|
||||
priceSelectorKeyword.value = ''
|
||||
priceSelectorSelected.value = []
|
||||
priceSelectorVisible.value = true
|
||||
try {
|
||||
const res = await fetchCellProductPriceList({ page: 1, pageSize: 100 })
|
||||
priceSelectorList.value = (res as any)?.list || []
|
||||
} catch {
|
||||
priceSelectorList.value = []
|
||||
}
|
||||
// Pre-check items already in detailItems (by sourcePriceId)
|
||||
await nextTick()
|
||||
const existingIds = new Set(detailItems.value.map((item) => item.sourcePriceId))
|
||||
const tableRef = priceSelectorTableRef.value
|
||||
if (tableRef) {
|
||||
priceSelectorList.value.forEach((row: any) => {
|
||||
if (existingIds.has(row.id)) {
|
||||
tableRef.toggleRowSelection(row, true)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function handlePriceSelectorChange(rows: any[]) {
|
||||
priceSelectorSelected.value = rows
|
||||
}
|
||||
|
||||
function handleConfirmPriceSelector() {
|
||||
// Filter out items that already exist in detailItems (by sourcePriceId)
|
||||
const existingIds = new Set(detailItems.value.map((item) => item.sourcePriceId))
|
||||
for (const row of priceSelectorSelected.value) {
|
||||
if (existingIds.has(row.id)) continue
|
||||
detailItems.value.push({
|
||||
sourcePriceId: row.id,
|
||||
projectName: row.projectName || '',
|
||||
projectCode: row.projectCode || '',
|
||||
cellTypeCode: row.cellTypeCode || '',
|
||||
cellTypeName: row.cellTypeName || '',
|
||||
specText: row.specText || '',
|
||||
specId: row.specId || '',
|
||||
cellProductTypeId: row.cellProductTypeId || '',
|
||||
unitPrice: row.unitPrice ?? null
|
||||
})
|
||||
}
|
||||
priceSelectorVisible.value = false
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadData()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.system-dialog-form {
|
||||
:deep(.el-form-item) {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.detail-section {
|
||||
margin-top: 20px;
|
||||
|
||||
.detail-section-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.detail-section-title {
|
||||
margin: 0;
|
||||
padding-left: 10px;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: #1e293b;
|
||||
border-left: 3px solid #10b981;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.detail-table {
|
||||
border: none !important;
|
||||
box-shadow: none !important;
|
||||
|
||||
&::before,
|
||||
&::after {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
:deep(.el-table__inner-wrapper) {
|
||||
border: none !important;
|
||||
|
||||
&::before {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.el-table__cell) {
|
||||
border-right: none !important;
|
||||
}
|
||||
|
||||
:deep(.el-table__body tr:last-child td.el-table__cell) {
|
||||
border-bottom: none !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user