gaoluyang
3 天以前 b92ea6fb8b4a75a0d7c561bd045f1a8b1720ddd1
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
59
60
<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>