<template>
|
<div class="home-container">
|
<div style="height: 100%">
|
<el-row class="homeCard">
|
<div class="basic-line">
|
<span>实验材料:</span>
|
<el-input v-model="materialState.searchQuery.stuffName" clearable filterable class="input-box" placeholder="实验材料">
|
</el-input>
|
</div>
|
<div class="basic-line">
|
<span>耗材编号:</span>
|
<el-input v-model="materialState.searchQuery.stuffCode" clearable filterable class="input-box" placeholder="耗材编号">
|
</el-input>
|
</div>
|
<div class="basic-line">
|
<span>材料类型:</span>
|
<el-select v-model="materialState.searchQuery.stuffType" clearable filterable class="input-box" placeholder="材料类型">
|
<el-option v-for="item in materialState.stuffTypeList" :key="item.id" :label="item.name" :value="item.id"></el-option>
|
</el-select>
|
</div>
|
<div style="padding-bottom: 10px">
|
<el-button type="primary" @click="getMaterialData">查询</el-button>
|
<el-button plain @click="reset">重置</el-button>
|
</div>
|
</el-row>
|
<div class="homeCard">
|
<div class="main-card">
|
<el-row class="cardTop">
|
<el-col :span="12" class="mainCardBtn">
|
<el-button type="primary" :icon="Plus" size="default" @click="openMaterialDialog('新增', {})">新增</el-button>
|
<!-- <el-button type="danger" :icon="Delete" size="default" plain>删除</el-button>-->
|
</el-col>
|
<!-- <el-button type="primary" :icon="Refresh" size="default" />-->
|
</el-row>
|
<el-table ref="multipleTableRef" :data="materialState.materialData" style="width: 100%" height="calc(100% - 100px)" :header-cell-style="{ background: '#fafafa' }">
|
<el-table-column prop="stuffName" label="实验材料"/>
|
<el-table-column prop="stuffCode" label="编号" />
|
<el-table-column prop="stuffType" label="材料类型">
|
<template #default="scope">
|
<span>{{`${materialState.stuffTypeList.find(item =>item.id === scope.row.stuffType)?.name || ''}`}}</span>
|
</template>
|
</el-table-column>
|
<el-table-column prop="stuffStorage" label="材料储存" show-overflow-tooltip>
|
<template #default="scope">
|
<span>{{`${materialState.stuffStorageList.find(item =>item.id === scope.row.stuffStorage)?.name || ''}`}}</span>
|
</template>
|
</el-table-column>
|
<el-table-column prop="stuffUnit" label="计量单位" show-overflow-tooltip>
|
<template #default="scope">
|
<span>{{`${materialState.stuffUnitList.find(item =>item.id === scope.row.stuffUnit)?.name || ''}`}}</span>
|
</template>
|
</el-table-column>
|
<el-table-column prop="createTime" label="创建时间" show-overflow-tooltip></el-table-column>
|
<el-table-column prop="createByUserName" label="创建人" show-overflow-tooltip></el-table-column>
|
<el-table-column prop="updateTime" label="最后修改时间" show-overflow-tooltip></el-table-column>
|
<el-table-column prop="updateByUserName" label="最后修改人" show-overflow-tooltip></el-table-column>
|
<el-table-column label="操作" width="150">
|
<template #default="scope">
|
<el-button size="small" text type="primary" :icon="Edit" @click="openMaterialDialog('修改', scope.row)">编辑</el-button>
|
<el-button size="small" text type="danger" :icon="Delete" @click="onDelMaterial(scope.row)">删除</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
<div class="pageBtn">
|
<el-pagination @size-change="onHandleSizeChange" @current-change="onHandleCurrentChange" :pager-count="5" :page-sizes="[10, 20, 30]" v-model:current-page="materialState.searchQuery.pageIndex" background v-model:page-size="materialState.searchQuery.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="materialState.total" class="page-position"> </el-pagination>
|
</div>
|
</div>
|
</div>
|
</div>
|
<material-dialog ref="materialDialogRef" @refresh="getMaterialData"></material-dialog>
|
</div>
|
</template>
|
|
<script setup lang="ts">
|
import {defineAsyncComponent, onMounted, reactive, ref} from "vue";
|
import { materialApi } from "/@/api/basic/material";
|
import {ElMessage, ElMessageBox} from "element-plus";
|
import { Edit, View, Plus, Delete } from '@element-plus/icons-vue';
|
|
const MaterialDialog = defineAsyncComponent(() => import('./components/materialDialog.vue'));
|
|
const materialDialogRef = ref();
|
|
const materialState = reactive<MaterialStateType>({
|
materialData: [],
|
searchQuery: {
|
pageIndex: 1,
|
pageSize: 10,
|
stuffName: '',
|
stuffCode: '',
|
stuffType: null,
|
},
|
total: 0,
|
stuffTypeList: [
|
{id: 1, name: '化学试剂'},
|
{id:2, name: '基础材料'}
|
],
|
stuffStorageList: [
|
{id:1, name: '智能试剂柜'},
|
{id:2, name: '普通储存柜'},
|
],
|
stuffUnitList: [
|
{id:1, name: 'g'},
|
{id:2, name: 'kg'},
|
{id:3, name: 'ml'},
|
{id:4, name: 'l'},
|
]
|
})
|
|
const getMaterialData = async () => {
|
let res = await materialApi().getMaterialByList(materialState.searchQuery);
|
if(res.data.code === 100){
|
materialState.materialData = res.data.data;
|
materialState.total = res.data.total;
|
}else{
|
ElMessage({
|
type: 'warning',
|
message: res.data.msg
|
});
|
}
|
};
|
|
const openMaterialDialog = (title: string, value: MaterialType) => {
|
materialDialogRef.value.showMaterialDialog(title, value);
|
};
|
|
const onDelMaterial = (val: MaterialType) => {
|
ElMessageBox.confirm(`此操作将永久删除该耗材:“${val.stuffName}”,是否继续?`, '提示', {
|
confirmButtonText: '确认',
|
cancelButtonText: '取消',
|
type: 'warning'
|
})
|
.then(async () => {
|
let res = await materialApi().deleteMaterialById({ id: val.id });
|
if (res.data.code === 100) {
|
ElMessage({
|
type: 'success',
|
duration: 2000,
|
message: '删除成功'
|
});
|
await getMaterialData();
|
} else {
|
ElMessage({
|
type: 'warning',
|
message: res.data.msg
|
});
|
}
|
})
|
.catch((error) => {
|
});
|
}
|
|
const onHandleSizeChange = (val: number) => {
|
materialState.searchQuery.pageSize = val;
|
getMaterialData();
|
};
|
|
const onHandleCurrentChange = (val: number) => {
|
materialState.searchQuery.pageIndex = val;
|
getMaterialData();
|
};
|
|
const reset = () => {
|
materialState.searchQuery = {
|
pageIndex: 1,
|
pageSize: 10,
|
stuffName: '',
|
stuffCode: '',
|
stuffType: null,
|
}
|
};
|
|
onMounted(() => {
|
getMaterialData()
|
})
|
|
</script>
|
|
<style scoped lang="scss">
|
$homeNavLengh: 8;
|
.home-container {
|
height: calc(100vh - 144px);
|
box-sizing: border-box;
|
overflow: hidden;
|
.homeCard {
|
width: 100%;
|
padding: 20px;
|
box-sizing: border-box;
|
background: #fff;
|
border-radius: 4px;
|
|
.main-card {
|
width: 100%;
|
height: 100%;
|
.cardTop {
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
margin-bottom: 20px;
|
.mainCardBtn {
|
margin: 0;
|
}
|
}
|
.pageBtn {
|
height: 60px;
|
display: flex;
|
align-items: center;
|
justify-content: right;
|
|
.demo-pagination-block + .demo-pagination-block {
|
margin-top: 10px;
|
}
|
.demo-pagination-block .demonstration {
|
margin-bottom: 16px;
|
}
|
}
|
}
|
&:last-of-type {
|
height: calc(100% - 100px);
|
}
|
}
|
.el-row {
|
display: flex;
|
align-items: center;
|
margin-bottom: 20px;
|
&:last-child {
|
margin-bottom: 0;
|
}
|
.grid-content {
|
align-items: center;
|
min-height: 36px;
|
}
|
|
.topInfo {
|
display: flex;
|
align-items: center;
|
font-size: 16px;
|
font-weight: bold;
|
|
& > div {
|
white-space: nowrap;
|
margin-right: 20px;
|
}
|
}
|
}
|
}
|
.stepItem {
|
width: 100%;
|
display: flex;
|
align-items: flex-start;
|
margin-bottom: 30px;
|
margin-left: 30px;
|
padding-bottom: 30px;
|
border-left: 2px solid #ccc;
|
&:first-of-type {
|
margin-top: 30px;
|
}
|
&:last-of-type {
|
margin-bottom: 0;
|
border-left: none;
|
}
|
.stepNum {
|
width: 30px;
|
height: 30px;
|
border-radius: 15px;
|
box-sizing: border-box;
|
color: #333;
|
border: 1px solid #999;
|
line-height: 28px;
|
text-align: center;
|
margin-right: 10px;
|
margin-left: -16px;
|
margin-top: -30px;
|
}
|
.stepCard {
|
width: 100%;
|
margin-top: -30px;
|
|
.box-card {
|
width: 100%;
|
&:deep(.el-card__header) {
|
padding: 10px 15px;
|
}
|
.card-header {
|
width: 100%;
|
display: flex;
|
justify-content: space-between;
|
align-items: center;
|
& > div:first-of-type {
|
margin-right: 80px;
|
font-size: 18px;
|
font-weight: bold;
|
}
|
}
|
}
|
}
|
&:hover .card-header {
|
color: #0098f5;
|
}
|
&:hover .stepNum {
|
border: 2px solid #0098f5;
|
color: #0098f5;
|
}
|
}
|
|
:deep(.el-date-editor) {
|
width: 100%;
|
}
|
.el-select {
|
width: 100%;
|
}
|
:deep(.el-textarea.is-disabled .el-textarea__inner) {
|
background-color: var(--el-card-bg-color);
|
color: var(--el-input-text-color, var(--el-text-color-regular));
|
}
|
:deep(.el-input.is-disabled .el-input__inner) {
|
color: var(--el-input-text-color, var(--el-text-color-regular));
|
}
|
:deep(.el-input.is-disabled .el-input__wrapper) {
|
background-color: var(--el-card-bg-color);
|
}
|
</style>
|