<template>
|
<tr class="m-color b-font" style="text-align: center">实验所用的仪器/设备</tr>
|
<tr>
|
<td class="w-16 m-color">设备名称</td>
|
<td class="w-16 m-color">编号</td>
|
<td class="w-16 m-color">额定功率</td>
|
<td class="w-16 m-color">是否特种</td>
|
<td class="w-16 m-color">设备数量</td>
|
<td class="w-16 m-color">操作</td>
|
</tr>
|
<tr v-for="(item,index) in selectEquipmentState.equipmentList" :key="index">
|
<td class="w-16">
|
<el-select :disabled="selectEquipmentState.disabled" filterable v-model="item.deviceId" @change="giveOtherEquipmentValue($event, index)">
|
<el-option
|
v-for="item in selectEquipmentState.allEquipmentList"
|
:key="item.id"
|
:value="item.id"
|
:label="item.deviceName"
|
>
|
</el-option>
|
</el-select>
|
</td>
|
<td class="w-16">
|
<el-input :disabled="selectEquipmentState.disabled" v-model="item.deviceCode" placeholder="请输入数量" />
|
</td>
|
<td class="w-16">
|
<el-input :disabled="selectEquipmentState.disabled" v-model="item.devicePower" />
|
</td>
|
<td class="w-16">
|
<el-radio-group :disabled="selectEquipmentState.disabled" v-model="item.specialDevice">
|
<el-radio :label="1">是</el-radio>
|
<el-radio :label="2">否</el-radio>
|
</el-radio-group>
|
</td>
|
<td class="w-16">
|
<el-input type="number" v-model="item.deviceUseCount" />
|
</td>
|
<td class="w-16">
|
<el-button :disabled="selectEquipmentState.disabled" type="danger" @click="deleteEquipmentItem(index)">删除</el-button>
|
</td>
|
</tr>
|
<tr style="text-align: center">
|
<el-button :disabled="selectEquipmentState.disabled" type="primary" shape="round" @click="addEquipmentItem()">
|
选择实验仪器
|
</el-button>
|
</tr>
|
</template>
|
|
<script setup lang="ts">
|
import {onMounted, reactive, watchEffect} from "vue";
|
import {ElMessage} from "element-plus";
|
import { equipmentApi } from "/@/api/basic/equipement";
|
|
let props = defineProps({
|
disabled: Boolean,
|
data: Array<AllEquipmentListType>
|
});
|
|
const selectEquipmentState = reactive<SelectEquipmentType>({
|
disabled: false,
|
equipmentList: [],
|
allEquipmentList: [],
|
});
|
|
watchEffect(() => {
|
selectEquipmentState.equipmentList = props.data as Array<AllEquipmentListType>
|
selectEquipmentState.disabled = props.disabled
|
});
|
|
const addEquipmentItem = () => {
|
selectEquipmentState.equipmentList.push({deviceId: null, deviceUseCount: null, deviceCode: '', deviceName: '', devicePower: '', specialDevice: '',});
|
};
|
|
const deleteEquipmentItem = (index: number) => {
|
selectEquipmentState.equipmentList.splice(index,1);
|
};
|
|
const getAllEquipmentList = async () => {
|
let res = await equipmentApi().getAllEquipment();
|
if(res.data.code === 100){
|
selectEquipmentState.allEquipmentList = JSON.parse(JSON.stringify(res.data.data));
|
}else{
|
ElMessage({
|
type: 'warning',
|
message: res.data.msg
|
})
|
}
|
};
|
|
const giveOtherEquipmentValue = (value: number, index:number) => {
|
const data = selectEquipmentState.allEquipmentList.find(item => item.id === value) as AllEquipmentListType
|
selectEquipmentState.equipmentList[index] = {
|
deviceId: data.id,
|
deviceUseCount: null,
|
deviceCode: data.deviceCode,
|
deviceName: data.deviceName,
|
devicePower: data.devicePower,
|
specialDevice: data.specialDevice
|
}
|
};
|
|
const formatList = (formatList: Array<AllEquipmentListType>) => {
|
selectEquipmentState.equipmentList = formatList
|
}
|
|
defineExpose({
|
dataList: selectEquipmentState.equipmentList,
|
formatList
|
});
|
|
onMounted(() => {
|
getAllEquipmentList();
|
});
|
</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>
|