maven
4 天以前 5fbfc19daae6017e0522b281b39ab102a685c06d
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
<template>
  <el-dialog :title="modalOptions.title" v-model="visible" @close="close">
    <EditForm ref="editFormRef" />
    <template #footer>
      <el-button @click="closeModal">{{ modalOptions.cancelText }}</el-button>
      <el-button type="primary" :loading="loading" @click="sendForm">
        {{ modalOptions.confirmText }}
      </el-button>
    </template>
  </el-dialog>
</template>
 
<script setup>
import { useModal } from "@/hooks/useModal";
import EditForm from "../Form/EditForm.vue";
import { updateRegistration } from "@/api/procurementManagement/procurementInvoiceLedger";
import { ElMessage } from "element-plus";
 
defineOptions({
  name: "来票台账编辑",
});
const emits = defineEmits(["success"]);
 
const editFormRef = ref();
const {
  id,
  visible,
  loading,
  openModal,
  modalOptions,
  handleConfirm,
  closeModal,
} = useModal({ title: "来票台账" });
 
const open = async (id) => {
  openModal(id);
  await nextTick();
  editFormRef.value.load(id);
};
 
const close = () => {
  editFormRef.value.resetForm();
  closeModal();
};
 
const sendForm = async () => {
  const form = editFormRef.value.form;
  const { code } = await updateRegistration(form);
  if (code === 200) {
    emits("success");
    ElMessage({ message: "操作成功", type: "success" });
    close();
  }
};
 
defineExpose({
  open,
});
</script>