<template>
|
<el-drawer v-model="visible" :title="modalOptions.title" direction="ltr">
|
<MaintenanceForm ref="maintenanceFormRef" />
|
<template #footer>
|
<el-button @click="closeModal">{{ modalOptions.cancelText }}</el-button>
|
<el-button type="primary" @click="sendForm" :loading="loading">
|
{{ modalOptions.confirmText }}
|
</el-button>
|
</template>
|
</el-drawer>
|
</template>
|
|
<script setup>
|
import MaintenanceForm from "../Form/MaintenanceForm.vue";
|
import { useModal } from "@/hooks/useModal";
|
import { addMaintenance } from "@/api/equipmentManagement/upkeep";
|
|
defineOptions({
|
name: "保养模态框",
|
});
|
|
const maintenanceFormRef = ref();
|
const emits = defineEmits(["ok"]);
|
|
const {
|
id,
|
visible,
|
loading,
|
openModal,
|
modalOptions,
|
handleConfirm,
|
closeModal,
|
} = useModal({ title: "设备维修" });
|
|
/**
|
* @desc 保存保养
|
*/
|
const sendForm = async () => {
|
loading.value = true;
|
const form = await maintenanceFormRef.value.getForm();
|
const { code } = await addMaintenance({ id: id.value, ...form });
|
if (code == 200) {
|
emits("ok");
|
maintenanceFormRef.value.resetForm();
|
closeModal();
|
}
|
loading.value = false;
|
};
|
|
const open = async (id, row) => {
|
openModal(id);
|
await nextTick();
|
maintenanceFormRef.value.setForm(row);
|
};
|
defineExpose({
|
open,
|
});
|
</script>
|
|
<style lang="scss" scoped></style>
|