<template>
|
<el-drawer v-model="visible" :title="modalOptions.title" direction="ltr">
|
<MaintainForm ref="maintainFormRef" />
|
<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 { useModal } from "@/hooks/useModal";
|
import MaintainForm from "../Form/MaintainForm.vue";
|
import { addMaintain } from "@/api/equipmentManagement/repair";
|
|
defineOptions({
|
name: "维修模态框",
|
});
|
|
const maintainFormRef = ref();
|
const emits = defineEmits(["ok"]);
|
|
const {
|
id,
|
visible,
|
loading,
|
openModal,
|
modalOptions,
|
handleConfirm,
|
closeModal,
|
} = useModal({ title: "设备维修" });
|
|
const sendForm = async () => {
|
loading.value = true;
|
const form = await maintainFormRef.value.getForm();
|
const { code } = await addMaintain({ id: id.value, ...form });
|
if (code == 200) {
|
emits("ok");
|
maintainFormRef.value.resetForm();
|
closeModal();
|
}
|
loading.value = false;
|
};
|
|
const open = async (id, row) => {
|
openModal(id);
|
await nextTick();
|
maintainFormRef.value.setForm(row);
|
};
|
|
defineExpose({
|
open,
|
});
|
</script>
|
|
<style lang="scss" scoped></style>
|