| | |
| | | placeholder="请输入保养结果" |
| | | type="text" /> |
| | | </el-form-item> |
| | | <el-form-item label="设备备件"> |
| | | <el-select v-model="form.sparePartsIds" :loading="loadingSparePartOptions" placeholder="请选择设备备件" multiple filterable> |
| | | <el-option |
| | | v-for="item in sparePartOptions" |
| | | :key="item.id" |
| | | :label="item.name" |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-form> |
| | | </FormDialog> |
| | | </template> |
| | |
| | | <script setup> |
| | | import FormDialog from "@/components/Dialog/FormDialog.vue"; |
| | | import { addMaintenance } from "@/api/equipmentManagement/upkeep"; |
| | | import {getSparePartsOptions} from "@/api/equipmentManagement/spareParts.js"; |
| | | import useFormData from "@/hooks/useFormData"; |
| | | import dayjs from "dayjs"; |
| | | import useUserStore from "@/store/modules/user"; |
| | |
| | | maintenanceActuallyTime: undefined, // 实际保养日期 |
| | | maintenanceResult: undefined, // 保养结果 |
| | | status: 0, // 保养状态 |
| | | sparePartsIds: undefined, |
| | | }); |
| | | const sparePartOptions = ref([]) |
| | | const loadingSparePartOptions = ref(true) |
| | | |
| | | const setForm = (data) => { |
| | | form.maintenanceActuallyName = |
| | |
| | | : dayjs().format("YYYY-MM-DD HH:mm:ss"); |
| | | form.maintenanceResult = data.maintenanceResult; |
| | | form.status = 1; // 默认状态为完结 |
| | | form.sparePartsIds = data.sparePartsIds; |
| | | }; |
| | | |
| | | const fetchSparePartOptions = (deviceLedgerId) => { |
| | | loadingSparePartOptions.value = true; |
| | | getSparePartsOptions({ deviceLedgerId: deviceLedgerId }).then((res) => { |
| | | if (res.code == 200) { |
| | | sparePartOptions.value = res.data || []; |
| | | } |
| | | }).finally(() => { |
| | | loadingSparePartOptions.value = false; |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @desc 保存保养 |
| | |
| | | visible.value = true; |
| | | await nextTick(); |
| | | setForm(row); |
| | | fetchSparePartOptions(row.deviceLedgerId) |
| | | }; |
| | | |
| | | defineExpose({ |