<template>
|
<tr class="m-color b-font" style="text-align: center">实验所用的仪器/设备</tr>
|
<tr>
|
<td class="w-16 m-color required">设备名称</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 required">设备数量</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)" @focus="checkAllEquipment($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 v-model="item.deviceCode"/>
|
</td>
|
<td class="w-16">
|
<el-input disabled v-model="item.devicePower" />
|
</td>
|
<td class="w-16">
|
<!-- <el-radio-group disabled v-model="item.specialDevice">-->
|
<!-- <el-radio :label="1">是</el-radio>-->
|
<!-- <el-radio :label="2">否</el-radio>-->
|
<!-- </el-radio-group>-->
|
<div>{{item.specialDevice == 1 ? '是' : item.specialDevice == 2 ? '否' : ''}}</div>
|
</td>
|
<td class="w-16">
|
<el-input :disabled="selectEquipmentState.disabled" 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" v-if="!selectEquipmentState.disabled">
|
<el-button type="primary" shape="round" @click="addEquipmentItem()">
|
添加现有实验仪器/设备
|
</el-button>
|
<el-button shape="round" @click="addNewEquipment('新增', {})">
|
新增实验仪器/设备配置
|
</el-button>
|
</tr>
|
<equipment-dialog ref="equipmentDialogRef" :equipmentTypeList="selectEquipmentState.equipmentTypeList"></equipment-dialog>
|
</template>
|
|
<script setup lang="ts">
|
import {defineAsyncComponent, onMounted, reactive, ref, watchEffect} from "vue";
|
import {ElMessage} from "element-plus";
|
import { equipmentApi } from "/@/api/basic/equipement";
|
|
let props = defineProps({
|
disabled: Boolean,
|
data: Array<AllEquipmentListType>
|
});
|
const equipmentDialog = defineAsyncComponent(() => import('/@/views/basic/equipment/components/equipmentDialog.vue'));
|
const selectEquipmentState = reactive<SelectEquipmentType>({
|
disabled: false,
|
equipmentList: [],
|
allEquipmentList: [],
|
equipmentTypeList: [],
|
specialDeviceList: [
|
{id: 1, name: '是'},
|
{id:2, name: '否'}
|
]
|
});
|
|
watchEffect(() => {
|
selectEquipmentState.equipmentList = props.data as Array<AllEquipmentListType>
|
selectEquipmentState.disabled = props.disabled
|
});
|
|
const equipmentDialogRef = ref();
|
|
const getAllType = async ()=>{
|
const res = await equipmentApi().getAllType();
|
if(res.data.code === 100){
|
selectEquipmentState.equipmentTypeList = res.data.data
|
}
|
}
|
|
const checkAllEquipment = () => {
|
getAllEquipmentList()
|
}
|
|
const addEquipmentItem = () => {
|
selectEquipmentState.equipmentList.push({deviceId: null, deviceUseCount: null, deviceCode: '', deviceName: '', devicePower: '', specialDevice: '',deviceUnit: null, safeProtect: null});
|
};
|
|
const addNewEquipment = (title: string, value: EquipmentType) => {
|
equipmentDialogRef.value.showEquipmentDialog(title, value, selectEquipmentState.specialDeviceList);
|
}
|
|
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,
|
deviceUnit: data.deviceUnit,
|
safeProtect: data.safeProtect,
|
}
|
};
|
|
const formatList = (formatList: Array<AllEquipmentListType>) => {
|
selectEquipmentState.equipmentList = formatList
|
}
|
|
defineExpose({
|
dataList: selectEquipmentState.equipmentList,
|
formatList
|
});
|
|
onMounted(() => {
|
getAllType();
|
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;
|
|
:deep(.el-input__wrapper ){
|
box-shadow: none;
|
}
|
|
&:last-of-type {
|
border-right: none;
|
}
|
|
&.required {
|
&::before {
|
content: "*";
|
display: inline-block;
|
color: red;
|
}
|
}
|
|
&.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;
|
}
|
</style>
|