<template>
|
<tr class="m-color b-font" style="text-align: center">实验所用的试剂或材料</tr>
|
<tr>
|
<td class="w-14 m-color">实验材料</td>
|
<td class="w-14 m-color">耗材ID</td>
|
<td class="w-14 m-color">材料类型</td>
|
<td class="w-14 m-color">材料储存</td>
|
<td class="w-14 m-color">计量单位</td>
|
<td class="w-14 m-color">使用数量</td>
|
<td class="w-14 m-color">操作</td>
|
</tr>
|
<tr v-for="(item,index) in selectMaterialState.materialList" :key="index">
|
<td class="w-14">
|
<el-select :disabled="selectMaterialState.disabled" filterable v-model="item.stuffId" @change="giveOtherMaterialValue($event, index)">
|
<el-option
|
v-for="item in selectMaterialState.allMaterialList"
|
:key="item.id"
|
:value="item.id"
|
:label="item.stuffName"
|
>
|
</el-option>
|
</el-select>
|
</td>
|
<td class="w-14">
|
<el-input :disabled="selectMaterialState.disabled" v-model="item.stuffCode" />
|
</td>
|
<td class="w-14">
|
<el-input :disabled="selectMaterialState.disabled" v-model="item.stuffType" />
|
</td>
|
<td class="w-14">
|
<el-input :disabled="selectMaterialState.disabled" v-model="item.stuffStorage" />
|
</td>
|
<td class="w-14">
|
<el-input :disabled="selectMaterialState.disabled" v-model="item.stuffUnit" />
|
</td>
|
<td class="w-14">
|
<el-input type="number" v-model="item.stuffUseCount" />
|
</td>
|
<td class="w-14">
|
<el-button type="danger" :disabled="selectMaterialState.disabled" @click="deleteMaterialItem(index)">删除</el-button>
|
</td>
|
</tr>
|
<tr style="text-align: center">
|
<el-button :disabled="selectMaterialState.disabled" type="primary" shape="round" @click="addMaterialItem()">
|
选择实验材料
|
</el-button>
|
</tr>
|
</template>
|
|
<script setup lang="ts">
|
import {onMounted, reactive, watchEffect} from "vue";
|
import { materialApi } from "/@/api/basic/material";
|
import {ElMessage} from "element-plus";
|
let props = defineProps({
|
disabled: Boolean,
|
data: Array<AllMaterialListType>
|
});
|
|
const selectMaterialState = reactive<SelectMaterialType>({
|
disabled: false,
|
materialList: [],
|
allMaterialList: [],
|
})
|
|
const addMaterialItem = () => {
|
selectMaterialState.materialList.push({stuffId: null, stuffUseCount: null, stuffName: '',stuffCode:'',stuffType: '', stuffStorage: '', stuffUnit: ''});
|
};
|
|
watchEffect(() => {
|
selectMaterialState.materialList = props.data as Array<AllMaterialListType>
|
selectMaterialState.disabled = props.disabled
|
});
|
|
const deleteMaterialItem = (index: number) => {
|
selectMaterialState.materialList.splice(index,1);
|
};
|
|
const getAllPersonList = async () => {
|
let res = await materialApi().getAllMaterial();
|
if(res.data.code === 100){
|
selectMaterialState.allMaterialList = JSON.parse(JSON.stringify(res.data.data));
|
}else{
|
ElMessage({
|
type: 'warning',
|
message: res.data.msg
|
})
|
}
|
};
|
|
const giveOtherMaterialValue = (value: number, index:number) => {
|
const data = selectMaterialState.allMaterialList.find(item => item.id === value) as AllMaterialListType
|
selectMaterialState.materialList[index] = {
|
stuffId: data.id,
|
stuffUseCount: data.stuffUseCount,
|
stuffName: data.stuffName,
|
stuffCode: data.stuffCode,
|
stuffType: data.stuffType,
|
stuffStorage: data.stuffStorage,
|
stuffUnit: data.stuffUnit
|
};
|
};
|
|
const formatList = (formatList: Array<AllMaterialListType>) => {
|
selectMaterialState.materialList = formatList
|
};
|
|
defineExpose({
|
dataList: selectMaterialState.materialList,
|
formatList
|
});
|
|
|
onMounted(() => {
|
getAllPersonList();
|
});
|
</script>
|
|
<style scoped lang="scss">
|
.site-layout-background {
|
background: #fff;
|
}
|
|
.report-table {
|
width: 100%;
|
border-collapse: collapse;
|
border: 1px solid #337ecc;
|
margin: 20px 0;
|
|
th {
|
padding: 10px 0;
|
border: 1px solid #337ecc;
|
border-left: none;
|
}
|
|
tr {
|
width: 100%;
|
height: 44px;
|
line-height: 42px;
|
border-bottom: 1px solid #ccc;
|
|
&:last-of-type {
|
border-bottom: none;
|
}
|
|
td {
|
border-right: 1px solid #ccc;
|
display: inline-block;
|
height: 44px;
|
vertical-align: middle;
|
text-align: center;
|
line-height: 42px;
|
|
&:last-of-type {
|
border-right: none;
|
}
|
|
&.w-14 {
|
width: calc((100/7)/100 * 100%);
|
}
|
|
&.w-16 {
|
width: calc((100/6)/100 * 100%);
|
}
|
|
&.w-18 {
|
width: 16.59%;
|
}
|
|
&.w-20 {
|
width: 20%;
|
}
|
|
&.w-25 {
|
width: 25%;
|
}
|
|
&.w-50 {
|
width: 50%;
|
}
|
|
&.w-75 {
|
width: 75%;
|
}
|
|
.ant-input {
|
height: 100%;
|
border: none;
|
background: #f5f7fa;
|
}
|
|
.ant-picker {
|
width: 100%;
|
height: 100%;
|
}
|
}
|
}
|
|
.b-font {
|
font-size: 16px;
|
font-weight: bolder;
|
}
|
}
|
|
.m-color {
|
color: #0c4995;
|
}
|
:deep(.el-input__wrapper ){
|
box-shadow: none;
|
}
|
</style>
|