add 下游上游批次管理
This commit is contained in:
parent
35018c3e3f
commit
a4148ff5b2
70
src/api/admin/PreBatchApi.ts
Normal file
70
src/api/admin/PreBatchApi.ts
Normal file
@ -0,0 +1,70 @@
|
||||
import { RequestParams } from './http-client'
|
||||
import { ContentType, HttpClient } from './http-client'
|
||||
import type {
|
||||
PreBatchDto,
|
||||
PreBatchPageInput,
|
||||
PreBatchPageResponse,
|
||||
PreBatchOutput,
|
||||
PreBatchAddInput,
|
||||
PreBatchUpdateInput
|
||||
} from '/@/api/types/preBatchType'
|
||||
|
||||
export class PreBatchApi extends HttpClient {
|
||||
/**
|
||||
* 获取分页列表
|
||||
*/
|
||||
getPage = (data: PreBatchPageInput, params: RequestParams = {}) =>
|
||||
this.request<PreBatchPageResponse>({
|
||||
path: `/api/admin/pre-batch/get-page`,
|
||||
method: 'POST',
|
||||
body: data,
|
||||
type: ContentType.Json,
|
||||
...params,
|
||||
})
|
||||
|
||||
/**
|
||||
* 获取单条数据
|
||||
*/
|
||||
get = (params: { id: number }, requestParams: RequestParams = {}) =>
|
||||
this.request<PreBatchOutput>({
|
||||
path: `/api/admin/pre-batch/get`,
|
||||
method: 'GET',
|
||||
query: { id: params.id },
|
||||
...requestParams,
|
||||
})
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
add = (data: PreBatchAddInput, params: RequestParams = {}) =>
|
||||
this.request<any>({
|
||||
path: `/api/admin/pre-batch/add`,
|
||||
method: 'POST',
|
||||
body: data,
|
||||
type: ContentType.Json,
|
||||
...params,
|
||||
})
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*/
|
||||
update = (data: PreBatchUpdateInput, params: RequestParams = {}) =>
|
||||
this.request<any>({
|
||||
path: `/api/admin/pre-batch/update`,
|
||||
method: 'PUT',
|
||||
body: data,
|
||||
type: ContentType.Json,
|
||||
...params,
|
||||
})
|
||||
|
||||
/**
|
||||
* 软删除
|
||||
*/
|
||||
softDelete = (params: { id: number }, requestParams: RequestParams = {}) =>
|
||||
this.request<any>({
|
||||
path: `/api/admin/pre-batch/soft-delete`,
|
||||
method: 'DELETE',
|
||||
query: params,
|
||||
...requestParams,
|
||||
})
|
||||
}
|
70
src/api/admin/UspBatchApi.ts
Normal file
70
src/api/admin/UspBatchApi.ts
Normal file
@ -0,0 +1,70 @@
|
||||
import { RequestParams } from './http-client'
|
||||
import { ContentType, HttpClient } from './http-client'
|
||||
import type {
|
||||
UspBatchDto,
|
||||
UspBatchPageInput,
|
||||
UspBatchPageResponse,
|
||||
UspBatchOutput,
|
||||
UspBatchAddInput,
|
||||
UspBatchUpdateInput
|
||||
} from '/@/api/types/uspBatchType'
|
||||
|
||||
export class UspBatchApi extends HttpClient {
|
||||
/**
|
||||
* 获取分页列表
|
||||
*/
|
||||
getPage = (data: UspBatchPageInput, params: RequestParams = {}) =>
|
||||
this.request<UspBatchPageResponse>({
|
||||
path: `/api/admin/pre-batch/get-page`,
|
||||
method: 'POST',
|
||||
body: data,
|
||||
type: ContentType.Json,
|
||||
...params,
|
||||
})
|
||||
|
||||
/**
|
||||
* 获取单条数据
|
||||
*/
|
||||
get = (params: { id: number }, requestParams: RequestParams = {}) =>
|
||||
this.request<UspBatchOutput>({
|
||||
path: `/api/admin/pre-batch/get`,
|
||||
method: 'GET',
|
||||
query: { id: params.id },
|
||||
...requestParams,
|
||||
})
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
add = (data: UspBatchAddInput, params: RequestParams = {}) =>
|
||||
this.request<any>({
|
||||
path: `/api/admin/pre-batch/add`,
|
||||
method: 'POST',
|
||||
body: data,
|
||||
type: ContentType.Json,
|
||||
...params,
|
||||
})
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*/
|
||||
update = (data: UspBatchUpdateInput, params: RequestParams = {}) =>
|
||||
this.request<any>({
|
||||
path: `/api/admin/pre-batch/update`,
|
||||
method: 'PUT',
|
||||
body: data,
|
||||
type: ContentType.Json,
|
||||
...params,
|
||||
})
|
||||
|
||||
/**
|
||||
* 软删除
|
||||
*/
|
||||
softDelete = (params: { id: number }, requestParams: RequestParams = {}) =>
|
||||
this.request<any>({
|
||||
path: `/api/admin/pre-batch/soft-delete`,
|
||||
method: 'DELETE',
|
||||
query: params,
|
||||
...requestParams,
|
||||
})
|
||||
}
|
60
src/api/types/preBatchType.ts
Normal file
60
src/api/types/preBatchType.ts
Normal file
@ -0,0 +1,60 @@
|
||||
import { ServiceResponse } from './response'
|
||||
import { ServiceRequestPage } from './pageInput'
|
||||
import { PageResponse } from './pageResponse'
|
||||
|
||||
// 过滤条件
|
||||
export interface PreBatchFilter {
|
||||
/** 预批次名称 */
|
||||
keyWord?: string | null
|
||||
/** 项目ID */
|
||||
projectId?: number | null
|
||||
/** 是否下游 */
|
||||
isDown?: boolean | null
|
||||
/** 开始时间 */
|
||||
stDate?: string | null
|
||||
/** 结束时间 */
|
||||
edDate?: string | null
|
||||
}
|
||||
|
||||
/**
|
||||
* 预批次分页数据接口
|
||||
*/
|
||||
export interface PreBatchPageDto {
|
||||
/** 主键ID */
|
||||
id: number
|
||||
/** 预批次名称 */
|
||||
preBatchName: string
|
||||
/** 预批次编号 */
|
||||
preBatchNo: string
|
||||
/** 项目ID */
|
||||
projectId?: number | null
|
||||
/** 创建用户真实姓名 */
|
||||
createdUserRealName?: string
|
||||
/** 创建时间 */
|
||||
createdTime: string
|
||||
}
|
||||
|
||||
/**
|
||||
* 预批次完整数据接口
|
||||
*/
|
||||
export interface PreBatchDto {
|
||||
/** 主键ID */
|
||||
id?: number
|
||||
/** 预批次名称 */
|
||||
preBatchName: string
|
||||
/** 预批次编号 */
|
||||
preBatchNo: string
|
||||
/** 项目ID */
|
||||
projectId?: number | null
|
||||
/** 是否下游 0否1是 */
|
||||
isDown?: boolean | null
|
||||
/** 滴度 */
|
||||
titer?: number | null
|
||||
}
|
||||
|
||||
export type PreBatchPageInput = ServiceRequestPage<PreBatchFilter>
|
||||
export type PreBatchPageResponse = ServiceResponse<PageResponse<PreBatchPageDto>>
|
||||
|
||||
export type PreBatchOutput = ServiceResponse<PreBatchDto>
|
||||
export type PreBatchAddInput = PreBatchDto
|
||||
export type PreBatchUpdateInput = PreBatchDto
|
64
src/api/types/uspBatchType.ts
Normal file
64
src/api/types/uspBatchType.ts
Normal file
@ -0,0 +1,64 @@
|
||||
import { ServiceResponse } from './response'
|
||||
import { ServiceRequestPage } from './pageInput'
|
||||
import { PageResponse } from './pageResponse'
|
||||
|
||||
// 过滤条件
|
||||
export interface UspBatchFilter {
|
||||
/** 关键字 */
|
||||
keyWord?: string | null
|
||||
/** 项目ID */
|
||||
projectId?: number | null
|
||||
/** 是否下游 */
|
||||
isDown?: boolean | null
|
||||
/** 开始时间 */
|
||||
stDate?: string | null
|
||||
/** 结束时间 */
|
||||
edDate?: string | null
|
||||
}
|
||||
|
||||
/**
|
||||
* USP批次分页数据接口
|
||||
*/
|
||||
export interface UspBatchPageDto {
|
||||
/** 主键ID */
|
||||
id: number
|
||||
/** USP批次名称 */
|
||||
uspBatchName: string
|
||||
/** USP批次编号 */
|
||||
uspBatchNo: string
|
||||
/** 项目ID */
|
||||
projectId?: number | null
|
||||
/** 是否下游 */
|
||||
isDown?: boolean | null
|
||||
/** 滴度 */
|
||||
titer?: number | null
|
||||
/** 创建用户真实姓名 */
|
||||
createdUserRealName?: string
|
||||
/** 创建时间 */
|
||||
createdTime: string
|
||||
}
|
||||
|
||||
/**
|
||||
* USP批次完整数据接口
|
||||
*/
|
||||
export interface UspBatchDto {
|
||||
/** 主键ID */
|
||||
id?: number
|
||||
/** USP批次名称 */
|
||||
uspBatchName: string
|
||||
/** USP批次编号 */
|
||||
uspBatchNo: string
|
||||
/** 项目ID */
|
||||
projectId?: number | null
|
||||
/** 是否下游 */
|
||||
isDown?: boolean | null
|
||||
/** 滴度 */
|
||||
titer?: number | null
|
||||
}
|
||||
|
||||
export type UspBatchPageInput = ServiceRequestPage<UspBatchFilter>
|
||||
export type UspBatchPageResponse = ServiceResponse<PageResponse<UspBatchPageDto>>
|
||||
|
||||
export type UspBatchOutput = ServiceResponse<UspBatchDto>
|
||||
export type UspBatchAddInput = UspBatchDto
|
||||
export type UspBatchUpdateInput = UspBatchDto
|
200
src/views/admin/dspbatch/components/prebatch-form.vue
Normal file
200
src/views/admin/dspbatch/components/prebatch-form.vue
Normal file
@ -0,0 +1,200 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visible"
|
||||
:title="title"
|
||||
width="600px"
|
||||
:before-close="handleClose"
|
||||
destroy-on-close
|
||||
>
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
label-width="100px"
|
||||
@keyup.enter="onSubmit"
|
||||
>
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="24">
|
||||
<el-form-item label="批次名称" prop="preBatchName">
|
||||
<el-input
|
||||
v-model="form.preBatchName"
|
||||
placeholder="请输入批次名称"
|
||||
clearable
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="批次编号" prop="preBatchNo">
|
||||
<el-input
|
||||
v-model="form.preBatchNo"
|
||||
placeholder="请输入批次编号"
|
||||
clearable
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="项目" prop="projectId">
|
||||
<el-select
|
||||
v-model="form.projectId"
|
||||
placeholder="请选择项目"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in projectOptions"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="handleClose">取消</el-button>
|
||||
<el-button type="primary" @click="onSubmit" :loading="loading">
|
||||
确认
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, nextTick, onMounted } from 'vue'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { PreBatchApi } from '/@/api/admin/PreBatchApi'
|
||||
import { ProjectApi } from '/@/api/admin/ProjectApi'
|
||||
import type { PreBatchDto } from '/@/api/types/preBatchType'
|
||||
|
||||
interface Props {
|
||||
title?: string
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
title: '批次信息'
|
||||
})
|
||||
|
||||
const emit = defineEmits<{
|
||||
ok: []
|
||||
}>()
|
||||
|
||||
const visible = ref(false)
|
||||
const loading = ref(false)
|
||||
const formRef = ref<FormInstance>()
|
||||
const isEdit = ref(false)
|
||||
|
||||
const form = reactive<PreBatchDto>({
|
||||
id: undefined,
|
||||
preBatchName: '',
|
||||
preBatchNo: '',
|
||||
projectId: null,
|
||||
isDown: true,
|
||||
titer: null
|
||||
})
|
||||
|
||||
const projectOptions = ref<Array<{ id: number; name: string }>>([])
|
||||
|
||||
const rules: FormRules = {
|
||||
preBatchName: [
|
||||
{ required: true, message: '请输入批次名称', trigger: 'blur' },
|
||||
{ max: 255, message: '批次名称长度不能超过255个字符', trigger: 'blur' }
|
||||
],
|
||||
preBatchNo: [
|
||||
{ required: true, message: '请输入批次编号', trigger: 'blur' },
|
||||
{ max: 50, message: '批次编号长度不能超过50个字符', trigger: 'blur' }
|
||||
],
|
||||
projectId: [
|
||||
{ required: true, message: '请选择项目', trigger: 'change' }
|
||||
]
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getProjectOptions()
|
||||
})
|
||||
|
||||
const open = (data?: PreBatchDto) => {
|
||||
visible.value = true
|
||||
isEdit.value = !!data?.id
|
||||
|
||||
nextTick(() => {
|
||||
if (data) {
|
||||
Object.assign(form, data)
|
||||
} else {
|
||||
resetForm()
|
||||
}
|
||||
formRef.value?.clearValidate()
|
||||
})
|
||||
}
|
||||
|
||||
const resetForm = () => {
|
||||
Object.assign(form, {
|
||||
id: undefined,
|
||||
preBatchName: '',
|
||||
preBatchNo: '',
|
||||
projectId: null,
|
||||
isDown: true,
|
||||
titer: null
|
||||
})
|
||||
}
|
||||
|
||||
const handleClose = () => {
|
||||
visible.value = false
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
const onSubmit = async () => {
|
||||
try {
|
||||
await formRef.value?.validate()
|
||||
loading.value = true
|
||||
|
||||
const api = new PreBatchApi()
|
||||
const res = isEdit.value
|
||||
? await api.update(form)
|
||||
: await api.add(form)
|
||||
|
||||
if (res.success) {
|
||||
ElMessage.success(isEdit.value ? '编辑成功' : '新增成功')
|
||||
emit('ok')
|
||||
handleClose()
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('提交失败:', error)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const getProjectOptions = async () => {
|
||||
try {
|
||||
const res = await new ProjectApi().getPage({
|
||||
currentPage: 1,
|
||||
pageSize: 10000
|
||||
})
|
||||
|
||||
if (res?.success) {
|
||||
projectOptions.value = res.data?.list?.map(item => ({
|
||||
id: item.id ?? 0,
|
||||
name: item.projectName ?? ''
|
||||
})) ?? []
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取项目列表失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
open
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.dialog-footer {
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
271
src/views/admin/dspbatch/index.vue
Normal file
271
src/views/admin/dspbatch/index.vue
Normal file
@ -0,0 +1,271 @@
|
||||
<template>
|
||||
<MyLayout>
|
||||
<el-card class="my-query-box" shadow="never">
|
||||
<el-form :model="state.filter" :inline="true" @keyup.enter="onQuery">
|
||||
<el-form-item label="关键字">
|
||||
<el-input
|
||||
v-model="state.filter.keyWord"
|
||||
placeholder="批次名称/编号"
|
||||
clearable
|
||||
style="width: 200px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="项目">
|
||||
<el-select
|
||||
v-model="state.filter.projectId"
|
||||
placeholder="请选择项目"
|
||||
clearable
|
||||
style="width: 200px"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in state.projectOptions"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="开始时间">
|
||||
<el-date-picker
|
||||
v-model="state.filter.stDate"
|
||||
type="date"
|
||||
placeholder="开始时间"
|
||||
style="width: 150px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="结束时间">
|
||||
<el-date-picker
|
||||
v-model="state.filter.edDate"
|
||||
type="date"
|
||||
placeholder="结束时间"
|
||||
style="width: 150px"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
|
||||
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="ele-Search" @click="onQuery">查询</el-button>
|
||||
<el-button v-auth="'api:admin:pre-batch:add'" type="primary" icon="ele-Plus" @click="onAdd">新增</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<el-card class="my-fill mt8" shadow="never">
|
||||
<el-table
|
||||
:data="state.preBatchListData"
|
||||
style="width: 100%"
|
||||
v-loading="state.loading"
|
||||
row-key="id"
|
||||
border
|
||||
>
|
||||
<el-table-column prop="preBatchName" label="批次名称" min-width="150" show-overflow-tooltip />
|
||||
<el-table-column prop="preBatchNo" label="批次编号" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column prop="projectId" label="项目" min-width="120" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
{{ getProjectName(row.projectId) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="createdUserRealName" label="创建者" min-width="100" show-overflow-tooltip />
|
||||
<el-table-column prop="createdTime" label="创建时间" min-width="160" show-overflow-tooltip />
|
||||
<el-table-column label="操作" width="200" fixed="right" header-align="center" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button
|
||||
v-if="auth('api:admin:pre-batch:update')"
|
||||
icon="ele-EditPen"
|
||||
size="small"
|
||||
text
|
||||
type="primary"
|
||||
@click="onEdit(row)"
|
||||
>编辑</el-button
|
||||
>
|
||||
<el-button
|
||||
v-if="auth('api:admin:pre-batch:soft-delete')"
|
||||
icon="ele-Delete"
|
||||
size="small"
|
||||
text
|
||||
type="danger"
|
||||
@click="onDelete(row)"
|
||||
>删除</el-button
|
||||
>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<div class="my-flex my-flex-end" style="margin-top: 10px">
|
||||
<el-pagination
|
||||
v-model:currentPage="state.pageInput.currentPage"
|
||||
v-model:page-size="state.pageInput.pageSize"
|
||||
:total="state.total"
|
||||
:page-sizes="[10, 20, 50, 100]"
|
||||
size="small"
|
||||
background
|
||||
@size-change="onSizeChange"
|
||||
@current-change="onCurrentChange"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
/>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
<PrebatchForm ref="preBatchFormRef" :title="state.formTitle" @ok="Query" />
|
||||
</MyLayout>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup name="admin/dspBatch">
|
||||
import { ref, reactive, onMounted, getCurrentInstance, defineAsyncComponent } from 'vue'
|
||||
import { PreBatchApi } from '/@/api/admin/PreBatchApi'
|
||||
import { ProjectApi } from '/@/api/admin/ProjectApi'
|
||||
import type { PreBatchDto, PreBatchPageInput, PreBatchPageDto } from '/@/api/types/preBatchType'
|
||||
import { auth } from '/@/utils/authFunction'
|
||||
|
||||
// 引入组件
|
||||
const PrebatchForm = defineAsyncComponent(() => import('./components/prebatch-form.vue'))
|
||||
|
||||
const { proxy } = getCurrentInstance() as any
|
||||
|
||||
const preBatchFormRef = ref()
|
||||
|
||||
const state = reactive({
|
||||
loading: false,
|
||||
formTitle: '',
|
||||
filter: {
|
||||
keyWord: '',
|
||||
projectId: null as number | null,
|
||||
isDown: true,
|
||||
stDate: '',
|
||||
edDate: ''
|
||||
},
|
||||
total: 0,
|
||||
pageInput: {
|
||||
currentPage: 1,
|
||||
pageSize: 20,
|
||||
} as PreBatchPageInput,
|
||||
preBatchListData: [] as Array<PreBatchPageDto>,
|
||||
projectOptions: [] as Array<{ id: number; name: string }>,
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
Query()
|
||||
getProjectOptions()
|
||||
})
|
||||
|
||||
const onQuery = () => {
|
||||
Query()
|
||||
}
|
||||
|
||||
const Query = async () => {
|
||||
state.loading = true
|
||||
state.pageInput.filter = state.filter
|
||||
try {
|
||||
const res = await new PreBatchApi().getPage(state.pageInput)
|
||||
state.preBatchListData = res?.data?.list ?? []
|
||||
state.total = res?.data?.total ?? 0
|
||||
} catch (error) {
|
||||
console.error('查询失败:', error)
|
||||
} finally {
|
||||
state.loading = false
|
||||
}
|
||||
}
|
||||
|
||||
const onAdd = () => {
|
||||
state.formTitle = '新增预批次'
|
||||
preBatchFormRef.value?.open()
|
||||
}
|
||||
|
||||
const onEdit = (row: PreBatchDto) => {
|
||||
state.formTitle = '编辑预批次'
|
||||
preBatchFormRef.value?.open(row)
|
||||
}
|
||||
|
||||
const onDelete = (row: PreBatchDto) => {
|
||||
proxy.$modal.confirm('确认要删除该记录吗?').then(async () => {
|
||||
try {
|
||||
const res = await new PreBatchApi().softDelete({ id: row.id! })
|
||||
if (res.success) {
|
||||
proxy.$modal.msgSuccess('删除成功')
|
||||
Query()
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('删除失败:', error)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const onSizeChange = (val: number) => {
|
||||
state.pageInput.pageSize = val
|
||||
Query()
|
||||
}
|
||||
|
||||
const onCurrentChange = (val: number) => {
|
||||
state.pageInput.currentPage = val
|
||||
Query()
|
||||
}
|
||||
|
||||
const onReset = () => {
|
||||
state.filter = {
|
||||
keyWord: '',
|
||||
projectId: null,
|
||||
isDown: true,
|
||||
stDate: '',
|
||||
edDate: ''
|
||||
}
|
||||
Query()
|
||||
}
|
||||
|
||||
const getProjectOptions = async () => {
|
||||
try {
|
||||
const res = await new ProjectApi().getPage({
|
||||
currentPage: 1,
|
||||
pageSize: 10000
|
||||
})
|
||||
|
||||
if (res?.success) {
|
||||
state.projectOptions = res.data?.list?.map(item => ({
|
||||
id: item.id ?? 0,
|
||||
name: item.projectName ?? ''
|
||||
})) ?? []
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取项目列表失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
const getProjectName = (projectId: number) => {
|
||||
const project = state.projectOptions.find(item => item.id === projectId)
|
||||
return project?.name ?? ''
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.my-query-box {
|
||||
:deep(.el-form-item) {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
.my-fill {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.my-flex {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.my-flex-between {
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.my-flex-end {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.mt8 {
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.mb8 {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
</style>
|
@ -288,8 +288,6 @@ const handleReactorSelect = async (data: { reactorId: number | null, remark: str
|
||||
reactorId: data.reactorId
|
||||
})
|
||||
|
||||
console.log('API 调用结果:', res)
|
||||
|
||||
if (res.success) {
|
||||
proxy.$modal.msgSuccess('复制成功')
|
||||
Query()
|
||||
|
200
src/views/admin/uspbatch/components/uspbatch-form.vue
Normal file
200
src/views/admin/uspbatch/components/uspbatch-form.vue
Normal file
@ -0,0 +1,200 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visible"
|
||||
:title="title"
|
||||
width="600px"
|
||||
:before-close="handleClose"
|
||||
destroy-on-close
|
||||
>
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
label-width="120px"
|
||||
@keyup.enter="onSubmit"
|
||||
>
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="24">
|
||||
<el-form-item label="USP批次名称" prop="uspBatchName">
|
||||
<el-input
|
||||
v-model="form.uspBatchName"
|
||||
placeholder="请输入USP批次名称"
|
||||
clearable
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="USP批次编号" prop="uspBatchNo">
|
||||
<el-input
|
||||
v-model="form.uspBatchNo"
|
||||
placeholder="请输入USP批次编号"
|
||||
clearable
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="项目" prop="projectId">
|
||||
<el-select
|
||||
v-model="form.projectId"
|
||||
placeholder="请选择项目"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in projectOptions"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="handleClose">取消</el-button>
|
||||
<el-button type="primary" @click="onSubmit" :loading="loading">
|
||||
确认
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, nextTick, onMounted } from 'vue'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { UspBatchApi } from '/@/api/admin/UspBatchApi'
|
||||
import { ProjectApi } from '/@/api/admin/ProjectApi'
|
||||
import type { UspBatchDto } from '/@/api/types/uspBatchType'
|
||||
|
||||
interface Props {
|
||||
title?: string
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
title: 'USP批次信息'
|
||||
})
|
||||
|
||||
const emit = defineEmits<{
|
||||
ok: []
|
||||
}>()
|
||||
|
||||
const visible = ref(false)
|
||||
const loading = ref(false)
|
||||
const formRef = ref<FormInstance>()
|
||||
const isEdit = ref(false)
|
||||
|
||||
const form = reactive<UspBatchDto>({
|
||||
id: undefined,
|
||||
uspBatchName: '',
|
||||
uspBatchNo: '',
|
||||
projectId: null,
|
||||
isDown: true,
|
||||
titer: null
|
||||
})
|
||||
|
||||
const projectOptions = ref<Array<{ id: number; name: string }>>([])
|
||||
|
||||
const rules: FormRules = {
|
||||
uspBatchName: [
|
||||
{ required: true, message: '请输入USP批次名称', trigger: 'blur' },
|
||||
{ max: 255, message: 'USP批次名称长度不能超过255个字符', trigger: 'blur' }
|
||||
],
|
||||
uspBatchNo: [
|
||||
{ required: true, message: '请输入USP批次编号', trigger: 'blur' },
|
||||
{ max: 50, message: 'USP批次编号长度不能超过50个字符', trigger: 'blur' }
|
||||
],
|
||||
projectId: [
|
||||
{ required: true, message: '请选择项目', trigger: 'change' }
|
||||
]
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getProjectOptions()
|
||||
})
|
||||
|
||||
const open = (data?: UspBatchDto) => {
|
||||
visible.value = true
|
||||
isEdit.value = !!data?.id
|
||||
|
||||
nextTick(() => {
|
||||
if (data) {
|
||||
Object.assign(form, data)
|
||||
} else {
|
||||
resetForm()
|
||||
}
|
||||
formRef.value?.clearValidate()
|
||||
})
|
||||
}
|
||||
|
||||
const resetForm = () => {
|
||||
Object.assign(form, {
|
||||
id: undefined,
|
||||
uspBatchName: '',
|
||||
uspBatchNo: '',
|
||||
projectId: null,
|
||||
isDown: true,
|
||||
titer: null
|
||||
})
|
||||
}
|
||||
|
||||
const handleClose = () => {
|
||||
visible.value = false
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
const onSubmit = async () => {
|
||||
try {
|
||||
await formRef.value?.validate()
|
||||
loading.value = true
|
||||
|
||||
const api = new UspBatchApi()
|
||||
const res = isEdit.value
|
||||
? await api.update(form)
|
||||
: await api.add(form)
|
||||
|
||||
if (res.success) {
|
||||
ElMessage.success(isEdit.value ? '编辑成功' : '新增成功')
|
||||
emit('ok')
|
||||
handleClose()
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('提交失败:', error)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const getProjectOptions = async () => {
|
||||
try {
|
||||
const res = await new ProjectApi().getPage({
|
||||
currentPage: 1,
|
||||
pageSize: 10000
|
||||
})
|
||||
|
||||
if (res?.success) {
|
||||
projectOptions.value = res.data?.list?.map(item => ({
|
||||
id: item.id ?? 0,
|
||||
name: item.projectName ?? ''
|
||||
})) ?? []
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取项目列表失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
open
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.dialog-footer {
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
281
src/views/admin/uspbatch/index.vue
Normal file
281
src/views/admin/uspbatch/index.vue
Normal file
@ -0,0 +1,281 @@
|
||||
<template>
|
||||
<MyLayout>
|
||||
<el-card class="my-query-box" shadow="never">
|
||||
<el-form :model="state.filter" :inline="true" @keyup.enter="onQuery">
|
||||
<el-form-item label="关键字">
|
||||
<el-input
|
||||
v-model="state.filter.keyWord"
|
||||
placeholder="USP批次名称/编号"
|
||||
clearable
|
||||
style="width: 200px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="项目">
|
||||
<el-select
|
||||
v-model="state.filter.projectId"
|
||||
placeholder="请选择项目"
|
||||
clearable
|
||||
style="width: 200px"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in state.projectOptions"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="创建时间">
|
||||
<el-date-picker
|
||||
v-model="state.filter.stDate"
|
||||
type="date"
|
||||
placeholder="开始日期"
|
||||
value-format="YYYY-MM-DD"
|
||||
style="width: 150px"
|
||||
/>
|
||||
-
|
||||
<el-date-picker
|
||||
v-model="state.filter.edDate"
|
||||
type="date"
|
||||
placeholder="结束日期"
|
||||
value-format="YYYY-MM-DD"
|
||||
style="width: 150px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="ele-Search" @click="onQuery">查询</el-button>
|
||||
<el-button icon="ele-Refresh" @click="onReset">重置</el-button>
|
||||
<el-button v-auth="'api:admin:uspbatch:add'" type="primary" icon="ele-Plus" @click="onAdd">新增</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<el-card class="my-fill mt8" shadow="never">
|
||||
<el-table
|
||||
:data="state.uspBatchListData"
|
||||
style="width: 100%"
|
||||
v-loading="state.loading"
|
||||
row-key="id"
|
||||
border
|
||||
>
|
||||
<el-table-column prop="uspBatchName" label="USP批次名称" min-width="150" show-overflow-tooltip />
|
||||
<el-table-column prop="uspBatchNo" label="USP批次编号" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column prop="projectId" label="项目" min-width="120" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
{{ getProjectName(row.projectId) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="isDown" label="是否下游" width="100" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag v-if="row.isDown" type="success">是</el-tag>
|
||||
<el-tag v-else type="info">否</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="titer" label="滴度" min-width="100" align="center" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
{{ row.titer || '-' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="createdUserRealName" label="创建者" min-width="100" show-overflow-tooltip />
|
||||
<el-table-column prop="createdTime" label="创建时间" min-width="160" show-overflow-tooltip />
|
||||
<el-table-column label="操作" width="200" fixed="right" header-align="center" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button
|
||||
v-if="auth('api:admin:uspbatch:update')"
|
||||
icon="ele-EditPen"
|
||||
size="small"
|
||||
text
|
||||
type="primary"
|
||||
@click="onEdit(row)"
|
||||
>编辑</el-button
|
||||
>
|
||||
<el-button
|
||||
v-if="auth('api:admin:uspbatch:soft-delete')"
|
||||
icon="ele-Delete"
|
||||
size="small"
|
||||
text
|
||||
type="danger"
|
||||
@click="onDelete(row)"
|
||||
>删除</el-button
|
||||
>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<div class="my-flex my-flex-end" style="margin-top: 10px">
|
||||
<el-pagination
|
||||
v-model:currentPage="state.pageInput.currentPage"
|
||||
v-model:page-size="state.pageInput.pageSize"
|
||||
:total="state.total"
|
||||
:page-sizes="[10, 20, 50, 100]"
|
||||
size="small"
|
||||
background
|
||||
@size-change="onSizeChange"
|
||||
@current-change="onCurrentChange"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
/>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
<uspbatch-form ref="uspBatchFormRef" :title="state.formTitle" @ok="Query" />
|
||||
</MyLayout>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup name="admin/uspBatch">
|
||||
import { ref, reactive, onMounted, getCurrentInstance, defineAsyncComponent } from 'vue'
|
||||
import { UspBatchApi } from '/@/api/admin/UspBatchApi'
|
||||
import { ProjectApi } from '/@/api/admin/ProjectApi'
|
||||
import type { UspBatchDto, UspBatchPageInput, UspBatchPageDto } from '/@/api/types/uspBatchType'
|
||||
import { auth } from '/@/utils/authFunction'
|
||||
|
||||
// 引入组件
|
||||
const UspBatchForm = defineAsyncComponent(() => import('./components/uspbatch-form.vue'))
|
||||
|
||||
const { proxy } = getCurrentInstance() as any
|
||||
|
||||
const uspBatchFormRef = ref()
|
||||
|
||||
const state = reactive({
|
||||
loading: false,
|
||||
formTitle: '',
|
||||
filter: {
|
||||
keyWord: '',
|
||||
projectId: null as number | null,
|
||||
isDown: true,
|
||||
stDate: '',
|
||||
edDate: ''
|
||||
},
|
||||
total: 0,
|
||||
pageInput: {
|
||||
currentPage: 1,
|
||||
pageSize: 20,
|
||||
} as UspBatchPageInput,
|
||||
uspBatchListData: [] as Array<UspBatchPageDto>,
|
||||
projectOptions: [] as Array<{ id: number; name: string }>,
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
Query()
|
||||
getProjectOptions()
|
||||
})
|
||||
|
||||
const onQuery = () => {
|
||||
Query()
|
||||
}
|
||||
|
||||
const Query = async () => {
|
||||
state.loading = true
|
||||
state.pageInput.filter = state.filter
|
||||
try {
|
||||
const res = await new UspBatchApi().getPage(state.pageInput)
|
||||
state.uspBatchListData = res?.data?.list ?? []
|
||||
state.total = res?.data?.total ?? 0
|
||||
} catch (error) {
|
||||
console.error('查询失败:', error)
|
||||
} finally {
|
||||
state.loading = false
|
||||
}
|
||||
}
|
||||
|
||||
const onAdd = () => {
|
||||
state.formTitle = '新增USP批次'
|
||||
uspBatchFormRef.value?.open()
|
||||
}
|
||||
|
||||
const onEdit = (row: UspBatchDto) => {
|
||||
state.formTitle = '编辑USP批次'
|
||||
uspBatchFormRef.value?.open(row)
|
||||
}
|
||||
|
||||
const onDelete = (row: UspBatchDto) => {
|
||||
proxy.$modal.confirm('确认要删除该记录吗?').then(async () => {
|
||||
try {
|
||||
const res = await new UspBatchApi().softDelete({ id: row.id! })
|
||||
if (res.success) {
|
||||
proxy.$modal.msgSuccess('删除成功')
|
||||
Query()
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('删除失败:', error)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const onSizeChange = (val: number) => {
|
||||
state.pageInput.pageSize = val
|
||||
Query()
|
||||
}
|
||||
|
||||
const onCurrentChange = (val: number) => {
|
||||
state.pageInput.currentPage = val
|
||||
Query()
|
||||
}
|
||||
|
||||
const onReset = () => {
|
||||
state.filter = {
|
||||
keyWord: '',
|
||||
projectId: null,
|
||||
isDown: true,
|
||||
stDate: '',
|
||||
edDate: ''
|
||||
}
|
||||
Query()
|
||||
}
|
||||
|
||||
const getProjectOptions = async () => {
|
||||
try {
|
||||
const res = await new ProjectApi().getPage({
|
||||
currentPage: 1,
|
||||
pageSize: 10000
|
||||
})
|
||||
|
||||
if (res?.success) {
|
||||
state.projectOptions = res.data?.list?.map(item => ({
|
||||
id: item.id ?? 0,
|
||||
name: item.projectName ?? ''
|
||||
})) ?? []
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取项目列表失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
const getProjectName = (projectId: number) => {
|
||||
const project = state.projectOptions.find(item => item.id === projectId)
|
||||
return project?.name ?? ''
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.my-query-box {
|
||||
:deep(.el-form-item) {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
.my-fill {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.my-flex {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.my-flex-between {
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.my-flex-end {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.mt8 {
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.mb8 {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
</style>
|
Loading…
x
Reference in New Issue
Block a user