add 初始培养基相关功能
This commit is contained in:
parent
d6112be661
commit
8638a7712f
@ -8154,3 +8154,74 @@ export interface FeedingConfigUpdateInput {
|
|||||||
*/
|
*/
|
||||||
id: number
|
id: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface BasicMediumDto {
|
||||||
|
/** 培养基名称 */
|
||||||
|
mediumName: string;
|
||||||
|
/** 状态 */
|
||||||
|
status: boolean;
|
||||||
|
/** 主键Id */
|
||||||
|
id: number;
|
||||||
|
/** 创建时间 */
|
||||||
|
createdTime: string;
|
||||||
|
/** 修改时间 */
|
||||||
|
modifiedTime: string;
|
||||||
|
/** 是否删除 */
|
||||||
|
isDeleted: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BasicMediumDtoListServiceResponse {
|
||||||
|
/** 是否成功标记 */
|
||||||
|
success?: boolean;
|
||||||
|
/** 编码 */
|
||||||
|
code?: string | null;
|
||||||
|
/** 消息 */
|
||||||
|
msg?: string | null;
|
||||||
|
/** 数据 */
|
||||||
|
data?: BasicMediumDto[] | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BasicMediumDtoServiceResponse {
|
||||||
|
/** 是否成功标记 */
|
||||||
|
success?: boolean;
|
||||||
|
/** 编码 */
|
||||||
|
code?: string | null;
|
||||||
|
/** 消息 */
|
||||||
|
msg?: string | null;
|
||||||
|
/** 数据 */
|
||||||
|
data?: BasicMediumDto | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始培养基相关接口定义
|
||||||
|
export interface PageInputBasicMediumDtoGetPageInput {
|
||||||
|
dynamicFilter?: DynamicFilterInfo;
|
||||||
|
sortList?: SortInput[] | null;
|
||||||
|
currentPage?: number;
|
||||||
|
pageSize?: number;
|
||||||
|
filter?: BasicMediumDtoGetPageInput;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BasicMediumDtoGetPageInput {
|
||||||
|
keyWord?: string | null;
|
||||||
|
stDate?: string | null;
|
||||||
|
edDate?: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PageOutputBasicMediumDtoGetPageOutput {
|
||||||
|
total?: number;
|
||||||
|
list?: BasicMediumDto[] | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ResultOutputPageOutputBasicMediumDtoGetPageOutput {
|
||||||
|
success?: boolean;
|
||||||
|
code?: string | null;
|
||||||
|
msg?: string | null;
|
||||||
|
data?: PageOutputBasicMediumDtoGetPageOutput;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ResultOutputBasicMediumDtoGetOutput {
|
||||||
|
success?: boolean;
|
||||||
|
code?: string | null;
|
||||||
|
msg?: string | null;
|
||||||
|
data?: BasicMediumDto;
|
||||||
|
}
|
||||||
|
156
src/api/admin/item-def-basic-medium.ts
Normal file
156
src/api/admin/item-def-basic-medium.ts
Normal file
@ -0,0 +1,156 @@
|
|||||||
|
/* eslint-disable */
|
||||||
|
/* tslint:disable */
|
||||||
|
/*
|
||||||
|
* ---------------------------------------------------------------
|
||||||
|
* ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ##
|
||||||
|
* ## ##
|
||||||
|
* ## AUTHOR: adademo / https://github.com/adademo/swagger-typescript-api ##
|
||||||
|
* ## SOURCE: https://github.com/adademo/swagger-typescript-api ##
|
||||||
|
* ---------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
import {
|
||||||
|
BasicMediumDto,
|
||||||
|
BasicMediumDtoListServiceResponse,
|
||||||
|
BasicMediumDtoServiceResponse,
|
||||||
|
PageInputBasicMediumDtoGetPageInput,
|
||||||
|
ResultOutputBasicMediumDtoGetOutput,
|
||||||
|
ResultOutputPageOutputBasicMediumDtoGetPageOutput,
|
||||||
|
ResultOutputInt64,
|
||||||
|
} from './data-contracts'
|
||||||
|
import { ContentType, HttpClient, RequestParams } from './http-client'
|
||||||
|
import { AxiosResponse } from 'axios'
|
||||||
|
|
||||||
|
export class ItemDefBasicMediumApi<SecurityDataType = unknown> extends HttpClient<SecurityDataType> {
|
||||||
|
/**
|
||||||
|
* No description
|
||||||
|
*
|
||||||
|
* @tags basic-medium
|
||||||
|
* @name Get
|
||||||
|
* @summary 获取初始培养基详情
|
||||||
|
* @request GET:/api/admin/item-def-basic-medium/get
|
||||||
|
* @secure
|
||||||
|
*/
|
||||||
|
get = (
|
||||||
|
query?: {
|
||||||
|
/** @format int64 */
|
||||||
|
id?: number
|
||||||
|
},
|
||||||
|
params: RequestParams = {}
|
||||||
|
) =>
|
||||||
|
this.request<ResultOutputBasicMediumDtoGetOutput, any>({
|
||||||
|
path: `/api/admin/item-def-basic-medium/get`,
|
||||||
|
method: 'GET',
|
||||||
|
query: query,
|
||||||
|
secure: true,
|
||||||
|
format: 'json',
|
||||||
|
...params,
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* No description
|
||||||
|
*
|
||||||
|
* @tags basic-medium
|
||||||
|
* @name GetPage
|
||||||
|
* @summary 获取初始培养基分页列表
|
||||||
|
* @request POST:/api/admin/item-def-basic-medium/get-page
|
||||||
|
* @secure
|
||||||
|
*/
|
||||||
|
getPage = (data: PageInputBasicMediumDtoGetPageInput, params: RequestParams = {}) =>
|
||||||
|
this.request<ResultOutputPageOutputBasicMediumDtoGetPageOutput, any>({
|
||||||
|
path: `/api/admin/item-def-basic-medium/get-page`,
|
||||||
|
method: 'POST',
|
||||||
|
body: data,
|
||||||
|
secure: true,
|
||||||
|
type: ContentType.Json,
|
||||||
|
format: 'json',
|
||||||
|
...params,
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* No description
|
||||||
|
*
|
||||||
|
* @tags basic-medium
|
||||||
|
* @name Add
|
||||||
|
* @summary 新增初始培养基
|
||||||
|
* @request POST:/api/admin/item-def-basic-medium/add
|
||||||
|
* @secure
|
||||||
|
*/
|
||||||
|
add = (data: BasicMediumDto, params: RequestParams = {}) =>
|
||||||
|
this.request<ResultOutputInt64, any>({
|
||||||
|
path: `/api/admin/item-def-basic-medium/add`,
|
||||||
|
method: 'POST',
|
||||||
|
body: data,
|
||||||
|
secure: true,
|
||||||
|
type: ContentType.Json,
|
||||||
|
format: 'json',
|
||||||
|
...params,
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* No description
|
||||||
|
*
|
||||||
|
* @tags basic-medium
|
||||||
|
* @name Update
|
||||||
|
* @summary 修改初始培养基
|
||||||
|
* @request PUT:/api/admin/item-def-basic-medium/update
|
||||||
|
* @secure
|
||||||
|
*/
|
||||||
|
update = (data: BasicMediumDto, params: RequestParams = {}) =>
|
||||||
|
this.request<AxiosResponse, any>({
|
||||||
|
path: `/api/admin/item-def-basic-medium/update`,
|
||||||
|
method: 'PUT',
|
||||||
|
body: data,
|
||||||
|
secure: true,
|
||||||
|
type: ContentType.Json,
|
||||||
|
...params,
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* No description
|
||||||
|
*
|
||||||
|
* @tags basic-medium
|
||||||
|
* @name Delete
|
||||||
|
* @summary 彻底删除初始培养基
|
||||||
|
* @request DELETE:/api/admin/item-def-basic-medium/delete
|
||||||
|
* @secure
|
||||||
|
*/
|
||||||
|
delete = (
|
||||||
|
query?: {
|
||||||
|
/** @format int64 */
|
||||||
|
id?: number
|
||||||
|
},
|
||||||
|
params: RequestParams = {}
|
||||||
|
) =>
|
||||||
|
this.request<AxiosResponse, any>({
|
||||||
|
path: `/api/admin/item-def-basic-medium/delete`,
|
||||||
|
method: 'DELETE',
|
||||||
|
query: query,
|
||||||
|
secure: true,
|
||||||
|
...params,
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* No description
|
||||||
|
*
|
||||||
|
* @tags basic-medium
|
||||||
|
* @name SoftDelete
|
||||||
|
* @summary 删除初始培养基
|
||||||
|
* @request DELETE:/api/admin/item-def-basic-medium/soft-delete
|
||||||
|
* @secure
|
||||||
|
*/
|
||||||
|
softDelete = (
|
||||||
|
query?: {
|
||||||
|
/** @format int64 */
|
||||||
|
id?: number
|
||||||
|
},
|
||||||
|
params: RequestParams = {}
|
||||||
|
) =>
|
||||||
|
this.request<AxiosResponse, any>({
|
||||||
|
path: `/api/admin/item-def-basic-medium/soft-delete`,
|
||||||
|
method: 'DELETE',
|
||||||
|
query: query,
|
||||||
|
secure: true,
|
||||||
|
...params,
|
||||||
|
})
|
||||||
|
}
|
20
src/types/data-contracts.ts
Normal file
20
src/types/data-contracts.ts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
export interface BasicMediumDto {
|
||||||
|
mediumName: string;
|
||||||
|
status: boolean;
|
||||||
|
id: number;
|
||||||
|
createdTime: string;
|
||||||
|
modifiedTime: string;
|
||||||
|
isDeleted: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BasicMediumDtoListServiceResponse {
|
||||||
|
data?: BasicMediumDto[] | null;
|
||||||
|
success?: boolean;
|
||||||
|
message?: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BasicMediumDtoServiceResponse {
|
||||||
|
data?: BasicMediumDto | null;
|
||||||
|
success?: boolean;
|
||||||
|
message?: string | null;
|
||||||
|
}
|
181
src/views/admin/basicliquid/components/BasicLiquidForm.vue
Normal file
181
src/views/admin/basicliquid/components/BasicLiquidForm.vue
Normal file
@ -0,0 +1,181 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<el-dialog
|
||||||
|
v-model="dialogVisible"
|
||||||
|
destroy-on-close
|
||||||
|
:title="formData.id ? '编辑培养基' : '新增培养基'"
|
||||||
|
draggable
|
||||||
|
:close-on-click-modal="false"
|
||||||
|
:close-on-press-escape="false"
|
||||||
|
width="900px"
|
||||||
|
>
|
||||||
|
<el-form
|
||||||
|
ref="formRef"
|
||||||
|
:model="form"
|
||||||
|
:rules="rules"
|
||||||
|
label-width="120px"
|
||||||
|
size="default"
|
||||||
|
>
|
||||||
|
<!-- 基本信息 -->
|
||||||
|
<div class="form-section">
|
||||||
|
<div class="section-title">基本信息</div>
|
||||||
|
<el-row :gutter="25">
|
||||||
|
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
|
||||||
|
<el-form-item label="培养基名称" prop="mediumName" :rules="[{ required: true, message: '请输入培养基名称', trigger: ['blur', 'change'] }]">
|
||||||
|
<el-input v-model="form.mediumName" clearable placeholder="请输入培养基名称" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
|
||||||
|
<el-form-item label="启用状态">
|
||||||
|
<el-switch
|
||||||
|
v-model="form.status"
|
||||||
|
active-text="启用"
|
||||||
|
inactive-text="禁用"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</div>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<template #footer>
|
||||||
|
<span class="dialog-footer">
|
||||||
|
<el-button @click="handleCancel" size="default">取 消</el-button>
|
||||||
|
<el-button type="primary" @click="handleSubmit" size="default" :loading="loading">确 定</el-button>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { ref, reactive, watch, computed } from 'vue'
|
||||||
|
import { ElMessage } from 'element-plus'
|
||||||
|
import type { FormInstance } from 'element-plus'
|
||||||
|
import { ItemDefBasicMediumApi } from '/@/api/admin/item-def-basic-medium'
|
||||||
|
import type { BasicMediumDto } from '/@/types/data-contracts'
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
visible: boolean
|
||||||
|
formData: Partial<BasicMediumDto>
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(e: 'update:visible', value: boolean): void
|
||||||
|
(e: 'success'): void
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const api = new ItemDefBasicMediumApi()
|
||||||
|
const formRef = ref<FormInstance>()
|
||||||
|
const loading = ref(false)
|
||||||
|
|
||||||
|
// 使用计算属性处理 visible 的双向绑定
|
||||||
|
const dialogVisible = computed({
|
||||||
|
get: () => props.visible,
|
||||||
|
set: (val) => emit('update:visible', val)
|
||||||
|
})
|
||||||
|
|
||||||
|
const form = reactive<Partial<BasicMediumDto>>({
|
||||||
|
mediumName: '',
|
||||||
|
status: true
|
||||||
|
})
|
||||||
|
|
||||||
|
const rules = {
|
||||||
|
mediumName: [
|
||||||
|
{ required: true, message: '请输入培养基名称', trigger: ['blur', 'change'] }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
// 监听 formData 变化,更新表单数据
|
||||||
|
watch(
|
||||||
|
() => props.formData,
|
||||||
|
(newVal) => {
|
||||||
|
if (newVal) {
|
||||||
|
Object.assign(form, newVal)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ immediate: true }
|
||||||
|
)
|
||||||
|
|
||||||
|
// 监听 visible 变化,重置表单
|
||||||
|
watch(
|
||||||
|
() => props.visible,
|
||||||
|
(newVal) => {
|
||||||
|
if (!newVal) {
|
||||||
|
formRef.value?.resetFields()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
const handleCancel = () => {
|
||||||
|
emit('update:visible', false)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleSubmit = async () => {
|
||||||
|
if (!formRef.value) return
|
||||||
|
|
||||||
|
await formRef.value.validate(async (valid) => {
|
||||||
|
if (valid) {
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
// 确保必填字段有值
|
||||||
|
const submitData: BasicMediumDto = {
|
||||||
|
mediumName: form.mediumName || '',
|
||||||
|
status: form.status ?? true,
|
||||||
|
id: form.id || 0,
|
||||||
|
createdTime: form.createdTime || new Date().toISOString(),
|
||||||
|
modifiedTime: new Date().toISOString(),
|
||||||
|
isDeleted: false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (form.id) {
|
||||||
|
// 编辑
|
||||||
|
const res = await api.update(submitData)
|
||||||
|
if (res.success) {
|
||||||
|
ElMessage.success('修改成功')
|
||||||
|
emit('success')
|
||||||
|
emit('update:visible', false)
|
||||||
|
} else {
|
||||||
|
ElMessage.error('修改失败')
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 新增
|
||||||
|
const res = await api.add(submitData)
|
||||||
|
if (res.success) {
|
||||||
|
ElMessage.success('新增成功')
|
||||||
|
emit('success')
|
||||||
|
emit('update:visible', false)
|
||||||
|
} else {
|
||||||
|
ElMessage.error(res.msg || '新增失败')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('操作失败:', error)
|
||||||
|
ElMessage.error('操作失败')
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.form-section {
|
||||||
|
margin-bottom: 24px;
|
||||||
|
|
||||||
|
.section-title {
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: bold;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
padding-left: 8px;
|
||||||
|
border-left: 4px solid var(--el-color-primary);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.dialog-footer {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
</style>
|
252
src/views/admin/basicliquid/index.vue
Normal file
252
src/views/admin/basicliquid/index.vue
Normal file
@ -0,0 +1,252 @@
|
|||||||
|
<template>
|
||||||
|
<MyLayout>
|
||||||
|
<el-card v-show="showQuery" class="my-query-box mt8" shadow="never" :body-style="{ paddingBottom: '0' }">
|
||||||
|
<el-form :inline="true" label-width="auto" @submit.stop.prevent>
|
||||||
|
<el-form-item label="关键词">
|
||||||
|
<el-input v-model="searchForm.keyWord" placeholder="培养基名称" @keyup.enter="loadData" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="开始时间">
|
||||||
|
<el-date-picker
|
||||||
|
v-model="searchForm.stDate"
|
||||||
|
type="datetime"
|
||||||
|
placeholder="选择开始时间"
|
||||||
|
format="YYYY-MM-DD HH:mm:ss"
|
||||||
|
value-format="YYYY-MM-DD HH:mm:ss"
|
||||||
|
style="width: 180px"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="结束时间">
|
||||||
|
<el-date-picker
|
||||||
|
v-model="searchForm.edDate"
|
||||||
|
type="datetime"
|
||||||
|
placeholder="选择结束时间"
|
||||||
|
format="YYYY-MM-DD HH:mm:ss"
|
||||||
|
value-format="YYYY-MM-DD HH:mm:ss"
|
||||||
|
style="width: 180px"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" icon="ele-Search" @click="loadData">查询</el-button>
|
||||||
|
<el-button type="primary" icon="ele-Plus" @click="handleAdd" v-permission="'api:admin:item-def-basic-medium:add'">新增</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</el-card>
|
||||||
|
|
||||||
|
<el-card class="my-fill" shadow="never">
|
||||||
|
<div class="my-tools-box mb8 my-flex my-flex-between">
|
||||||
|
<div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<el-table
|
||||||
|
v-loading="loading"
|
||||||
|
:data="tableData"
|
||||||
|
style="width: 100%"
|
||||||
|
border
|
||||||
|
>
|
||||||
|
<el-table-column prop="mediumName" label="培养基名称" min-width="300" show-overflow-tooltip />
|
||||||
|
<el-table-column prop="status" label="状态" width="200" align="center">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-tag :type="row.status ? 'success' : 'danger'">
|
||||||
|
{{ row.status ? '启用' : '禁用' }}
|
||||||
|
</el-tag>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="createdTime" label="创建时间" width="200" show-overflow-tooltip>
|
||||||
|
<template #default="{ row }">
|
||||||
|
{{ formatDateTime(row.createdTime) }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="modifiedTime" label="修改时间" width="200" show-overflow-tooltip>
|
||||||
|
<template #default="{ row }">
|
||||||
|
{{ formatDateTime(row.modifiedTime) }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="操作" width="200" fixed="right" header-align="center" align="center">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-button type="primary" icon="ele-EditPen" size="small" text @click="handleEdit(row)" v-permission="'api:admin:item-def-basic-medium:get'">编辑</el-button>
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
icon="ele-Delete"
|
||||||
|
size="small"
|
||||||
|
text
|
||||||
|
@click="handleDelete(row)"
|
||||||
|
v-permission="'api:admin:item-def-basic-medium:soft-delete'"
|
||||||
|
>删除</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
|
||||||
|
<div class="my-flex my-flex-end" style="margin-top: 10px">
|
||||||
|
<el-pagination
|
||||||
|
v-model:current-page="pagination.current"
|
||||||
|
v-model:page-size="pagination.pageSize"
|
||||||
|
:total="pagination.total"
|
||||||
|
:page-sizes="[10, 20, 50, 100]"
|
||||||
|
size="small"
|
||||||
|
background
|
||||||
|
layout="total, sizes, prev, pager, next, jumper"
|
||||||
|
@size-change="handleSizeChange"
|
||||||
|
@current-change="handleCurrentChange"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</el-card>
|
||||||
|
|
||||||
|
<basic-liquid-form
|
||||||
|
v-model:visible="formVisible"
|
||||||
|
:form-data="formData"
|
||||||
|
@success="handleSuccess"
|
||||||
|
/>
|
||||||
|
</MyLayout>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { ref, reactive, onMounted } from 'vue'
|
||||||
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
|
import { ItemDefBasicMediumApi } from '/@/api/admin/item-def-basic-medium'
|
||||||
|
import type { BasicMediumDto } from '/@/types/data-contracts'
|
||||||
|
import MyLayout from '/@/components/my-layout/index.vue'
|
||||||
|
import BasicLiquidForm from './components/BasicLiquidForm.vue'
|
||||||
|
|
||||||
|
const api = new ItemDefBasicMediumApi()
|
||||||
|
const loading = ref(false)
|
||||||
|
const tableData = ref<BasicMediumDto[]>([])
|
||||||
|
const formVisible = ref(false)
|
||||||
|
const formData = ref<Partial<BasicMediumDto>>({})
|
||||||
|
const showQuery = ref(true)
|
||||||
|
|
||||||
|
const searchForm = reactive({
|
||||||
|
keyWord: '',
|
||||||
|
stDate: '',
|
||||||
|
edDate: ''
|
||||||
|
})
|
||||||
|
|
||||||
|
const pagination = reactive({
|
||||||
|
total: 0,
|
||||||
|
current: 1,
|
||||||
|
pageSize: 10
|
||||||
|
})
|
||||||
|
|
||||||
|
// 格式化日期时间
|
||||||
|
const formatDateTime = (dateTime: string | undefined) => {
|
||||||
|
if (!dateTime) return ''
|
||||||
|
const date = new Date(dateTime)
|
||||||
|
const year = date.getFullYear()
|
||||||
|
const month = String(date.getMonth() + 1).padStart(2, '0')
|
||||||
|
const day = String(date.getDate()).padStart(2, '0')
|
||||||
|
const hours = String(date.getHours()).padStart(2, '0')
|
||||||
|
const minutes = String(date.getMinutes()).padStart(2, '0')
|
||||||
|
const seconds = String(date.getSeconds()).padStart(2, '0')
|
||||||
|
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载数据
|
||||||
|
const loadData = async () => {
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
const res = await api.getPage({
|
||||||
|
currentPage: pagination.current,
|
||||||
|
pageSize: pagination.pageSize,
|
||||||
|
filter: searchForm
|
||||||
|
})
|
||||||
|
if (res.success) {
|
||||||
|
tableData.value = res.data?.list || []
|
||||||
|
pagination.total = res.data?.total || 0
|
||||||
|
} else {
|
||||||
|
ElMessage.error(res.msg || '加载数据失败')
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('加载数据失败:', error)
|
||||||
|
ElMessage.error('加载数据失败')
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleAdd = () => {
|
||||||
|
formData.value = {}
|
||||||
|
formVisible.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleEdit = (row: BasicMediumDto) => {
|
||||||
|
formData.value = { ...row }
|
||||||
|
formVisible.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleDelete = async (row: BasicMediumDto) => {
|
||||||
|
ElMessageBox.confirm('确定要删除该记录吗?', '提示', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning'
|
||||||
|
}).then(async () => {
|
||||||
|
try {
|
||||||
|
const res = await api.softDelete({ id: row.id })
|
||||||
|
if (res.success) {
|
||||||
|
ElMessage.success('删除成功')
|
||||||
|
loadData()
|
||||||
|
} else {
|
||||||
|
ElMessage.error(res.msg || '删除失败')
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('删除失败:', error)
|
||||||
|
ElMessage.error('删除失败')
|
||||||
|
}
|
||||||
|
}).catch(() => {})
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleSuccess = () => {
|
||||||
|
formVisible.value = false
|
||||||
|
loadData()
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleSizeChange = (val: number) => {
|
||||||
|
pagination.pageSize = val
|
||||||
|
loadData()
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleCurrentChange = (val: number) => {
|
||||||
|
pagination.current = val
|
||||||
|
loadData()
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
loadData()
|
||||||
|
})
|
||||||
|
</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-tools-box {
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.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