zhangwencui
7 小时以前 a4203d1c0e24a69b3de3a4cf9f3cb1d727602224
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
61
62
63
64
65
66
<template>
  <el-dialog :title="modalOptions.title"
             v-model="visible"
             @close="close">
    <EditForm ref="editFormRef" />
    <template #footer>
      <el-button type="primary"
                 :loading="loading"
                 @click="sendForm">
        {{ modalOptions.confirmText }}
      </el-button>
      <el-button @click="closeModal">{{ modalOptions.cancelText }}</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 saleLedgerProjectId = ref("");
  const editFormRef = ref();
  const {
    id,
    visible,
    loading,
    openModal,
    modalOptions,
    handleConfirm,
    closeModal,
  } = useModal({ title: "来票台账" });
 
  const open = async row => {
    openModal(row.id);
    saleLedgerProjectId.value = row.saleLedgerProjectId;
    await nextTick();
    editFormRef.value.load(row.id, row.purchaseLedgerId, row.productModelId);
  };
 
  const close = () => {
    editFormRef.value.resetForm();
    closeModal();
  };
 
  const sendForm = async () => {
    const form = editFormRef.value.form;
    form.saleLedgerProjectId = saleLedgerProjectId.value;
    const { code } = await updateRegistration(form);
    if (code === 200) {
      emits("success");
      ElMessage({ message: "操作成功", type: "success" });
      close();
    }
  };
 
  defineExpose({
    open,
  });
</script>