| | |
| | | import { addLedger, editLedger } from "@/api/equipmentManagement/ledger"; |
| | | import Form from "./Form.vue"; |
| | | import { ElMessage } from "element-plus"; |
| | | const { proxy } = getCurrentInstance() |
| | | |
| | | defineOptions({ |
| | | name: "设备台账新增编辑", |
| | |
| | | closeModal, |
| | | } = useModal({ title: "设备台账" }); |
| | | |
| | | const sendForm = async () => { |
| | | loading.value = true; |
| | | const { code } = id.value |
| | | ? await editLedger({ id: id.value, ...formRef.value.form }) |
| | | : await addLedger(formRef.value.form); |
| | | if (code == 200) { |
| | | emits("success"); |
| | | ElMessage({ message: "操作成功", type: "success" }); |
| | | close(); |
| | | } else { |
| | | loading.value = false; |
| | | } |
| | | const sendForm = () => { |
| | | proxy.$refs.formRef.$refs.formRef.validate(async valid => { |
| | | if (valid) { |
| | | const {code} = id.value |
| | | ? await editLedger({id: id.value, ...formRef.value.form}) |
| | | : await addLedger(formRef.value.form); |
| | | if (code == 200) { |
| | | emits("success"); |
| | | ElMessage({message: "操作成功", type: "success"}); |
| | | close(); |
| | | } else { |
| | | loading.value = false; |
| | | } |
| | | } |
| | | }) |
| | | }; |
| | | |
| | | const close = () => { |
| | | formRef.value.resetForm(); |
| | | formRef.value.resetFormAndValidate(); |
| | | closeModal(); |
| | | }; |
| | | |