add 液袋管理页面
This commit is contained in:
parent
3b6fd601f2
commit
e49e4ef1bc
@ -8377,3 +8377,55 @@ export interface ResultOutputCellDtoGetOutput {
|
|||||||
message: string
|
message: string
|
||||||
data: CellDto
|
data: CellDto
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface BagDto {
|
||||||
|
itemDescription?: string | null
|
||||||
|
model?: number
|
||||||
|
capacity?: number
|
||||||
|
tareWeight?: number
|
||||||
|
lowerLimitVolume?: number
|
||||||
|
residualVolume?: number
|
||||||
|
materialIcon?: string | null
|
||||||
|
status?: boolean
|
||||||
|
id?: number
|
||||||
|
createdTime?: string
|
||||||
|
modifiedTime?: string
|
||||||
|
isDeleted?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BagModelEnum {
|
||||||
|
value?: number
|
||||||
|
name?: string | null
|
||||||
|
label?: string | null
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PageInputBagDtoGetPageInput {
|
||||||
|
filter?: BagDtoGetPageInput
|
||||||
|
currentPage?: number
|
||||||
|
pageSize?: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BagDtoGetPageInput {
|
||||||
|
keyWord?: string | null
|
||||||
|
stDate?: string | null
|
||||||
|
edDate?: string | null
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ResultOutputPageOutputBagDtoGetPageOutput {
|
||||||
|
success?: boolean
|
||||||
|
code?: string | null
|
||||||
|
message?: string | null
|
||||||
|
data?: PageOutputBagDtoGetPageOutput
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PageOutputBagDtoGetPageOutput {
|
||||||
|
list?: BagDto[] | null
|
||||||
|
total?: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ResultOutputBagDtoGetOutput {
|
||||||
|
success?: boolean
|
||||||
|
code?: string | null
|
||||||
|
message?: string | null
|
||||||
|
data?: BagDto
|
||||||
|
}
|
||||||
|
155
src/api/admin/item-def-bag.ts
Normal file
155
src/api/admin/item-def-bag.ts
Normal file
@ -0,0 +1,155 @@
|
|||||||
|
/* 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 {
|
||||||
|
BagDto,
|
||||||
|
BagModelEnum,
|
||||||
|
PageInputBagDtoGetPageInput,
|
||||||
|
ResultOutputBagDtoGetOutput,
|
||||||
|
ResultOutputPageOutputBagDtoGetPageOutput,
|
||||||
|
ResultOutputInt64,
|
||||||
|
} from './data-contracts'
|
||||||
|
import { ContentType, HttpClient, RequestParams } from './http-client'
|
||||||
|
import { AxiosResponse } from 'axios'
|
||||||
|
|
||||||
|
export class ItemDefBagApi<SecurityDataType = unknown> extends HttpClient<SecurityDataType> {
|
||||||
|
/**
|
||||||
|
* No description
|
||||||
|
*
|
||||||
|
* @tags item-def-bag
|
||||||
|
* @name Get
|
||||||
|
* @summary 获取液袋详情
|
||||||
|
* @request GET:/api/admin/item-def-bag/get
|
||||||
|
* @secure
|
||||||
|
*/
|
||||||
|
get = (
|
||||||
|
query?: {
|
||||||
|
/** @format int64 */
|
||||||
|
id?: number
|
||||||
|
},
|
||||||
|
params: RequestParams = {}
|
||||||
|
) =>
|
||||||
|
this.request<ResultOutputBagDtoGetOutput, any>({
|
||||||
|
path: `/api/admin/item-def-bag/get`,
|
||||||
|
method: 'GET',
|
||||||
|
query: query,
|
||||||
|
secure: true,
|
||||||
|
format: 'json',
|
||||||
|
...params,
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* No description
|
||||||
|
*
|
||||||
|
* @tags item-def-bag
|
||||||
|
* @name GetPage
|
||||||
|
* @summary 获取液袋分页列表
|
||||||
|
* @request POST:/api/admin/item-def-bag/get-page
|
||||||
|
* @secure
|
||||||
|
*/
|
||||||
|
getPage = (data: PageInputBagDtoGetPageInput, params: RequestParams = {}) =>
|
||||||
|
this.request<ResultOutputPageOutputBagDtoGetPageOutput, any>({
|
||||||
|
path: `/api/admin/item-def-bag/get-page`,
|
||||||
|
method: 'POST',
|
||||||
|
body: data,
|
||||||
|
secure: true,
|
||||||
|
type: ContentType.Json,
|
||||||
|
format: 'json',
|
||||||
|
...params,
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* No description
|
||||||
|
*
|
||||||
|
* @tags item-def-bag
|
||||||
|
* @name Add
|
||||||
|
* @summary 新增液袋
|
||||||
|
* @request POST:/api/admin/item-def-bag/add
|
||||||
|
* @secure
|
||||||
|
*/
|
||||||
|
add = (data: BagDto, params: RequestParams = {}) =>
|
||||||
|
this.request<ResultOutputInt64, any>({
|
||||||
|
path: `/api/admin/item-def-bag/add`,
|
||||||
|
method: 'POST',
|
||||||
|
body: data,
|
||||||
|
secure: true,
|
||||||
|
type: ContentType.Json,
|
||||||
|
format: 'json',
|
||||||
|
...params,
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* No description
|
||||||
|
*
|
||||||
|
* @tags item-def-bag
|
||||||
|
* @name Update
|
||||||
|
* @summary 修改液袋
|
||||||
|
* @request PUT:/api/admin/item-def-bag/update
|
||||||
|
* @secure
|
||||||
|
*/
|
||||||
|
update = (data: BagDto, params: RequestParams = {}) =>
|
||||||
|
this.request<AxiosResponse, any>({
|
||||||
|
path: `/api/admin/item-def-bag/update`,
|
||||||
|
method: 'PUT',
|
||||||
|
body: data,
|
||||||
|
secure: true,
|
||||||
|
type: ContentType.Json,
|
||||||
|
...params,
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* No description
|
||||||
|
*
|
||||||
|
* @tags item-def-bag
|
||||||
|
* @name Delete
|
||||||
|
* @summary 彻底删除液袋
|
||||||
|
* @request DELETE:/api/admin/item-def-bag/delete
|
||||||
|
* @secure
|
||||||
|
*/
|
||||||
|
delete = (
|
||||||
|
query?: {
|
||||||
|
/** @format int64 */
|
||||||
|
id?: number
|
||||||
|
},
|
||||||
|
params: RequestParams = {}
|
||||||
|
) =>
|
||||||
|
this.request<AxiosResponse, any>({
|
||||||
|
path: `/api/admin/item-def-bag/delete`,
|
||||||
|
method: 'DELETE',
|
||||||
|
query: query,
|
||||||
|
secure: true,
|
||||||
|
...params,
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* No description
|
||||||
|
*
|
||||||
|
* @tags item-def-bag
|
||||||
|
* @name SoftDelete
|
||||||
|
* @summary 删除液袋
|
||||||
|
* @request DELETE:/api/admin/item-def-bag/soft-delete
|
||||||
|
* @secure
|
||||||
|
*/
|
||||||
|
softDelete = (
|
||||||
|
query?: {
|
||||||
|
/** @format int64 */
|
||||||
|
id?: number
|
||||||
|
},
|
||||||
|
params: RequestParams = {}
|
||||||
|
) =>
|
||||||
|
this.request<AxiosResponse, any>({
|
||||||
|
path: `/api/admin/item-def-bag/soft-delete`,
|
||||||
|
method: 'DELETE',
|
||||||
|
query: query,
|
||||||
|
secure: true,
|
||||||
|
...params,
|
||||||
|
})
|
||||||
|
}
|
@ -6,6 +6,7 @@ export interface MittType {
|
|||||||
refreshFeedMedium: void
|
refreshFeedMedium: void
|
||||||
refreshBasicMedium: void
|
refreshBasicMedium: void
|
||||||
refreshCell: void
|
refreshCell: void
|
||||||
|
refreshLiquidBag: void
|
||||||
}
|
}
|
||||||
|
|
||||||
const emitter: Emitter<MittType> = mitt<MittType>()
|
const emitter: Emitter<MittType> = mitt<MittType>()
|
||||||
|
192
src/views/admin/liquidbag/components/liquid-bag-form.vue
Normal file
192
src/views/admin/liquidbag/components/liquid-bag-form.vue
Normal file
@ -0,0 +1,192 @@
|
|||||||
|
<template>
|
||||||
|
<el-dialog
|
||||||
|
v-model="state.dialogVisible"
|
||||||
|
:title="props.title"
|
||||||
|
width="900px"
|
||||||
|
:close-on-click-modal="false"
|
||||||
|
:close-on-press-escape="false"
|
||||||
|
draggable
|
||||||
|
destroy-on-close
|
||||||
|
>
|
||||||
|
<el-form
|
||||||
|
ref="formRef"
|
||||||
|
:model="form"
|
||||||
|
:rules="rules"
|
||||||
|
label-width="120px"
|
||||||
|
@submit.prevent
|
||||||
|
>
|
||||||
|
<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="itemDescription">
|
||||||
|
<el-input v-model="form.itemDescription" placeholder="请输入描述" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
|
||||||
|
<el-form-item label="型号" prop="model">
|
||||||
|
<el-select v-model="form.model" placeholder="请选择型号" style="width: 100%;">
|
||||||
|
<el-option
|
||||||
|
v-for="item in state.modelList"
|
||||||
|
:key="item.value"
|
||||||
|
:label="item.label"
|
||||||
|
:value="item.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
|
||||||
|
<el-form-item label="容量(g)" prop="capacity">
|
||||||
|
<el-input-number v-model="form.capacity" :min="0" style="width: 100%;" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
|
||||||
|
<el-form-item label="皮重(g)" prop="tareWeight">
|
||||||
|
<el-input-number v-model="form.tareWeight" :min="0" style="width: 100%;" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
|
||||||
|
<el-form-item label="下限体积(g)" prop="lowerLimitVolume">
|
||||||
|
<el-input-number v-model="form.lowerLimitVolume" :min="0" style="width: 100%;" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
|
||||||
|
<el-form-item label="残余量" prop="residualVolume">
|
||||||
|
<el-input-number v-model="form.residualVolume" :min="0" style="width: 100%;" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
|
||||||
|
<el-form-item label="状态" prop="status">
|
||||||
|
<el-switch v-model="form.status" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</div>
|
||||||
|
</el-form>
|
||||||
|
<template #footer>
|
||||||
|
<span class="dialog-footer">
|
||||||
|
<el-button @click="state.dialogVisible = false" size="default">取 消</el-button>
|
||||||
|
<el-button type="primary" @click="onSubmit" size="default" :loading="state.sureLoading">确 定</el-button>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { ref, reactive, onMounted } from 'vue'
|
||||||
|
import { BagDto, BagModelEnum } from '/@/api/admin/data-contracts'
|
||||||
|
import { ItemDefBagApi } from '/@/api/admin/item-def-bag'
|
||||||
|
import { DictApi } from '/@/api/admin/Dict'
|
||||||
|
import eventBus from '/@/utils/mitt'
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
title: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const formRef = ref()
|
||||||
|
|
||||||
|
const state = reactive({
|
||||||
|
dialogVisible: false,
|
||||||
|
sureLoading: false,
|
||||||
|
modelList: [] as BagModelEnum[],
|
||||||
|
})
|
||||||
|
|
||||||
|
const form = reactive<Partial<BagDto>>({
|
||||||
|
id: 0,
|
||||||
|
itemDescription: '',
|
||||||
|
model: undefined,
|
||||||
|
capacity: 0,
|
||||||
|
tareWeight: 0,
|
||||||
|
lowerLimitVolume: 0,
|
||||||
|
residualVolume: 0,
|
||||||
|
status: true,
|
||||||
|
})
|
||||||
|
|
||||||
|
const rules = {
|
||||||
|
itemDescription: [{ required: true, message: '请输入描述', trigger: 'blur' }],
|
||||||
|
model: [{ required: true, message: '请选择型号', trigger: 'change' }],
|
||||||
|
capacity: [{ required: true, message: '请输入容量', trigger: 'blur' }],
|
||||||
|
tareWeight: [{ required: true, message: '请输入皮重', trigger: 'blur' }],
|
||||||
|
lowerLimitVolume: [{ required: true, message: '请输入下限体积', trigger: 'blur' }],
|
||||||
|
residualVolume: [{ required: true, message: '请输入残余量', trigger: 'blur' }],
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
try {
|
||||||
|
const res = await new DictApi().getList(['bag_model'])
|
||||||
|
if (res?.data?.bag_model) {
|
||||||
|
state.modelList = res.data.bag_model.map((item: any) => ({
|
||||||
|
value: Number(item.value) || 1,
|
||||||
|
label: item.name || '',
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取型号列表失败:', error)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const open = (row?: Partial<BagDto>) => {
|
||||||
|
state.dialogVisible = true
|
||||||
|
if (row) {
|
||||||
|
Object.assign(form, row)
|
||||||
|
if (typeof row.model === 'object' && row.model !== null) {
|
||||||
|
form.model = row.model
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Object.assign(form, {
|
||||||
|
id: 0,
|
||||||
|
itemDescription: '',
|
||||||
|
model: undefined,
|
||||||
|
capacity: 0,
|
||||||
|
tareWeight: 0,
|
||||||
|
lowerLimitVolume: 0,
|
||||||
|
residualVolume: 0,
|
||||||
|
status: true,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const onSubmit = async () => {
|
||||||
|
if (!formRef.value) return
|
||||||
|
state.sureLoading = true
|
||||||
|
await formRef.value.validate(async (valid: boolean) => {
|
||||||
|
if (valid) {
|
||||||
|
if (form.id) {
|
||||||
|
await new ItemDefBagApi().update(form as BagDto, { loading: true })
|
||||||
|
} else {
|
||||||
|
await new ItemDefBagApi().add(form as BagDto, { loading: true })
|
||||||
|
}
|
||||||
|
state.dialogVisible = false
|
||||||
|
eventBus.emit('refreshLiquidBag')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
state.sureLoading = false
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
open
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.form-section {
|
||||||
|
border: 1px solid #dcdfe6;
|
||||||
|
padding: 20px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
border-radius: 4px;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-title {
|
||||||
|
position: absolute;
|
||||||
|
top: -10px;
|
||||||
|
left: 10px;
|
||||||
|
background-color: #fff;
|
||||||
|
padding: 0 10px;
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
</style>
|
218
src/views/admin/liquidbag/index.vue
Normal file
218
src/views/admin/liquidbag/index.vue
Normal file
@ -0,0 +1,218 @@
|
|||||||
|
<template>
|
||||||
|
<my-layout>
|
||||||
|
<el-card class="my-query-box mt8" shadow="never" :body-style="{ paddingBottom: '0' }">
|
||||||
|
<el-form :inline="true" @submit.stop.prevent>
|
||||||
|
<el-form-item label="关键词">
|
||||||
|
<el-input v-model="state.filter.keyWord" placeholder="描述" @keyup.enter="onQuery" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="开始时间">
|
||||||
|
<el-date-picker
|
||||||
|
v-model="state.filter.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="state.filter.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="onQuery"> 查询 </el-button>
|
||||||
|
<el-button v-auth="'api:admin:item-def-bag: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.bagListData"
|
||||||
|
style="width: 100%"
|
||||||
|
v-loading="state.loading"
|
||||||
|
border
|
||||||
|
>
|
||||||
|
<el-table-column prop="itemDescription" label="描述" min-width="180" show-overflow-tooltip />
|
||||||
|
<el-table-column label="型号" min-width="120" show-overflow-tooltip>
|
||||||
|
<template #default="{ row }">
|
||||||
|
{{ getModelName(row.model) }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="capacity" label="容量(g)" min-width="120" show-overflow-tooltip />
|
||||||
|
<el-table-column prop="tareWeight" label="皮重(g)" min-width="120" show-overflow-tooltip />
|
||||||
|
<el-table-column prop="lowerLimitVolume" label="下限体积(g)" min-width="120" show-overflow-tooltip />
|
||||||
|
<el-table-column prop="residualVolume" label="残余量(g)" min-width="120" show-overflow-tooltip />
|
||||||
|
<el-table-column label="状态" width="80" align="center" show-overflow-tooltip>
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-tag type="success" v-if="row.status">启用</el-tag>
|
||||||
|
<el-tag type="danger" v-else>禁用</el-tag>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="createdTime" label="创建时间" :formatter="formatterTime" 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:item-def-bag:update')"
|
||||||
|
icon="ele-EditPen"
|
||||||
|
size="small"
|
||||||
|
text
|
||||||
|
type="primary"
|
||||||
|
@click="onEdit(row)"
|
||||||
|
>编辑</el-button
|
||||||
|
>
|
||||||
|
<el-button
|
||||||
|
v-if="auth('api:admin:item-def-bag: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>
|
||||||
|
|
||||||
|
<liquid-bag-form ref="liquidBagFormRef" :title="state.formTitle"></liquid-bag-form>
|
||||||
|
</my-layout>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup name="admin/liquidbag">
|
||||||
|
import { ref, reactive, onMounted, getCurrentInstance, onBeforeMount, defineAsyncComponent } from 'vue'
|
||||||
|
import { BagDto, PageInputBagDtoGetPageInput } from '/@/api/admin/data-contracts'
|
||||||
|
import { ItemDefBagApi } from '/@/api/admin/item-def-bag'
|
||||||
|
import eventBus from '/@/utils/mitt'
|
||||||
|
import { auth } from '/@/utils/authFunction'
|
||||||
|
import dayjs from 'dayjs'
|
||||||
|
import { BagModelEnum } from '/@/api/admin/data-contracts'
|
||||||
|
import { DictApi } from '/@/api/admin/Dict'
|
||||||
|
|
||||||
|
const LiquidBagForm = defineAsyncComponent(() => import('./components/liquid-bag-form.vue'))
|
||||||
|
|
||||||
|
const { proxy } = getCurrentInstance() as any
|
||||||
|
|
||||||
|
const liquidBagFormRef = ref()
|
||||||
|
|
||||||
|
const state = reactive({
|
||||||
|
loading: false,
|
||||||
|
formTitle: '',
|
||||||
|
filter: {
|
||||||
|
keyWord: '',
|
||||||
|
stDate: '',
|
||||||
|
edDate: ''
|
||||||
|
},
|
||||||
|
total: 0,
|
||||||
|
pageInput: {
|
||||||
|
currentPage: 1,
|
||||||
|
pageSize: 20,
|
||||||
|
filter: {
|
||||||
|
keyWord: '',
|
||||||
|
stDate: '',
|
||||||
|
edDate: ''
|
||||||
|
},
|
||||||
|
} as PageInputBagDtoGetPageInput,
|
||||||
|
bagListData: [] as Array<BagDto>,
|
||||||
|
modelOptions: [] as BagModelEnum[],
|
||||||
|
})
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
getModelOptions()
|
||||||
|
onQuery()
|
||||||
|
eventBus.on('refreshLiquidBag', () => {
|
||||||
|
onQuery()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
onBeforeMount(() => {
|
||||||
|
eventBus.off('refreshLiquidBag')
|
||||||
|
})
|
||||||
|
|
||||||
|
const formatterTime = (row: any, column: any, cellValue: any) => {
|
||||||
|
return cellValue ? dayjs(cellValue).format('YYYY-MM-DD HH:mm:ss') : ''
|
||||||
|
}
|
||||||
|
|
||||||
|
const getModelOptions = async () => {
|
||||||
|
const res = await new DictApi().getList(['bag_model'])
|
||||||
|
if (res?.data?.bag_model) {
|
||||||
|
state.modelOptions = res.data.bag_model.map((item: any) => ({
|
||||||
|
value: Number(item.value) || 1,
|
||||||
|
label: item.name || '',
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const onQuery = async () => {
|
||||||
|
state.loading = true
|
||||||
|
if (state.pageInput.filter) {
|
||||||
|
state.pageInput.filter.keyWord = state.filter.keyWord
|
||||||
|
state.pageInput.filter.stDate = state.filter.stDate || null
|
||||||
|
state.pageInput.filter.edDate = state.filter.edDate
|
||||||
|
}
|
||||||
|
const res = await new ItemDefBagApi().getPage(state.pageInput).catch(() => {
|
||||||
|
state.loading = false
|
||||||
|
})
|
||||||
|
state.bagListData = res?.data?.list ?? []
|
||||||
|
state.total = res?.data?.total ?? 0
|
||||||
|
state.loading = false
|
||||||
|
}
|
||||||
|
|
||||||
|
const onAdd = () => {
|
||||||
|
state.formTitle = '新增液袋'
|
||||||
|
liquidBagFormRef.value.open()
|
||||||
|
}
|
||||||
|
|
||||||
|
const onEdit = (row: BagDto) => {
|
||||||
|
state.formTitle = '编辑液袋'
|
||||||
|
liquidBagFormRef.value.open(row)
|
||||||
|
}
|
||||||
|
|
||||||
|
const onDelete = (row: BagDto) => {
|
||||||
|
proxy.$modal
|
||||||
|
.confirmDelete(`确定要删除项目【${row.itemDescription}】?`)
|
||||||
|
.then(async () => {
|
||||||
|
await new ItemDefBagApi().softDelete({ id: row.id }, { loading: true })
|
||||||
|
onQuery()
|
||||||
|
})
|
||||||
|
.catch(() => {})
|
||||||
|
}
|
||||||
|
|
||||||
|
const onSizeChange = (val: number) => {
|
||||||
|
state.pageInput.currentPage = 1
|
||||||
|
state.pageInput.pageSize = val
|
||||||
|
onQuery()
|
||||||
|
}
|
||||||
|
|
||||||
|
const onCurrentChange = (val: number) => {
|
||||||
|
state.pageInput.currentPage = val
|
||||||
|
onQuery()
|
||||||
|
}
|
||||||
|
|
||||||
|
const getModelName = (modelValue: number) => {
|
||||||
|
const model = state.modelOptions.find(item => item.value === modelValue)
|
||||||
|
return model ? model.label : modelValue
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss"></style>
|
Loading…
x
Reference in New Issue
Block a user