曹睿
21 小时以前 f36f2f20bfb06dc3ca1b69c8a6d260d09d7d70ba
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<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>