changes
This commit is contained in:
@@ -79,7 +79,6 @@
|
||||
import { onMounted, defineAsyncComponent, shallowRef, watchEffect } from "vue";
|
||||
|
||||
const emit = defineEmits(["close", "remove", "select", "dataevent", "update"]);
|
||||
const { $store } = useNuxtApp();
|
||||
|
||||
const props = defineProps({
|
||||
component: String,
|
||||
|
||||
@@ -167,7 +167,7 @@ const props = defineProps({
|
||||
searchfield: Array,
|
||||
});
|
||||
|
||||
const { $copy, $dialog, $empty, $find, $findapi, $findIndex, $getdata, $id, $nonAccent, $store } = useNuxtApp();
|
||||
const { $copy, $dialog, $empty, $find, $findapi, $findIndex, $getdata, $nonAccent, $store } = useNuxtApp();
|
||||
const emit = defineEmits(["option", "modalevent"]);
|
||||
const suggestions = ref([]);
|
||||
const isLoading = ref(false);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<script setup>
|
||||
const { $dayjs } = useNuxtApp();
|
||||
const props = defineProps({
|
||||
date: String,
|
||||
});
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
</template>
|
||||
<script setup>
|
||||
const emit = defineEmits(["close"]);
|
||||
const { $store, $getdata, $patchapi, $updatepage } = useNuxtApp();
|
||||
const { $getdata, $patchapi, $updatepage } = useNuxtApp();
|
||||
const props = defineProps({
|
||||
row: Object,
|
||||
pagename: String,
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<script setup>
|
||||
const props = defineProps(["row", "pagename"]);
|
||||
const { $copyToClipboard } = useNuxtApp();
|
||||
|
||||
const phone = props.row.customer__phone || props.row.party__phone || props.row.phone;
|
||||
const format = (s) => `${s.slice(0, 3)} ${s.slice(3, 6)} ${s.slice(6, 20)}`;
|
||||
|
||||
@@ -68,17 +68,14 @@
|
||||
></Modal>
|
||||
</template>
|
||||
<script setup>
|
||||
import { computed, ref } from "vue";
|
||||
import { useNuxtApp } from "#app";
|
||||
import CustomerForm from "~/components/customer/CustomerForm.vue";
|
||||
import CustomerView from "~/components/customer/CustomerView.vue";
|
||||
import Modal from "~/components/Modal.vue";
|
||||
import ImageGallery from "~/components/media/ImageGallery.vue";
|
||||
const nuxtApp = useNuxtApp();
|
||||
const { $dialog } = nuxtApp;
|
||||
const { $dialog } = useNuxtApp();
|
||||
|
||||
const store = useStore();
|
||||
var props = defineProps({
|
||||
const props = defineProps({
|
||||
pagename: String,
|
||||
row: Object,
|
||||
application: Object,
|
||||
@@ -86,8 +83,7 @@ var props = defineProps({
|
||||
handleCustomer: Function,
|
||||
});
|
||||
|
||||
const lang = computed(() => store.lang);
|
||||
const isVietnamese = computed(() => lang.value === "vi");
|
||||
const isVietnamese = computed(() => store.lang === "vi");
|
||||
const emit = defineEmits(["modalevent", "close"]);
|
||||
var viewport = 5;
|
||||
var tabs = [
|
||||
|
||||
@@ -282,7 +282,7 @@
|
||||
</button>
|
||||
<button
|
||||
class="button is-light"
|
||||
@click="exportPdf(docid, { filename: record.code })"
|
||||
@click="$exportPdf(docid, { filename: record.code })"
|
||||
>
|
||||
In thông tin
|
||||
</button>
|
||||
|
||||
@@ -438,7 +438,7 @@ const props = defineProps({
|
||||
filterData: Object,
|
||||
width: String,
|
||||
});
|
||||
const { $copy, $stripHtml, $arrayMove, $snackbar, $copyToClipboard } = useNuxtApp();
|
||||
const { $copy, $stripHtml, $arrayMove, $snackbar } = useNuxtApp();
|
||||
const emit = defineEmits(["modalevent", "changepos", "close"]);
|
||||
const store = useStore();
|
||||
const { colorchoice } = store;
|
||||
|
||||
@@ -455,7 +455,7 @@
|
||||
<script setup>
|
||||
import { ref } from "vue";
|
||||
const store = useStore();
|
||||
const { $id, $copy, $empty, $stripHtml, $calc, $remove, $copyToClipboard } = useNuxtApp();
|
||||
const { $id, $copy, $empty, $calc, $remove, $copyToClipboard } = useNuxtApp();
|
||||
var props = defineProps({
|
||||
pagename: String,
|
||||
field: Object,
|
||||
|
||||
@@ -149,7 +149,6 @@ const {
|
||||
$parseNum,
|
||||
$multiSort,
|
||||
$remove,
|
||||
$stripHtml,
|
||||
$unique,
|
||||
} = useNuxtApp();
|
||||
const store = useStore();
|
||||
|
||||
@@ -246,7 +246,7 @@
|
||||
import CreateTemplate from "~/components/datatable/CreateTemplate";
|
||||
import FilterOption from "~/components/datatable/FilterOption.vue";
|
||||
import TableOption from "~/components/datatable/TableOption.vue";
|
||||
const { $id, $copy, $empty, $stripHtml } = useNuxtApp();
|
||||
const { $id, $copy, $empty } = useNuxtApp();
|
||||
const props = defineProps({
|
||||
event: Object,
|
||||
currentField: Object,
|
||||
|
||||
@@ -119,7 +119,7 @@ const props = defineProps({
|
||||
data: Object,
|
||||
focus: Boolean,
|
||||
});
|
||||
const { $empty, $copy, $copyToClipboard, $stripHtml, $patchapi, $insertapi, $findIndex, $snackbar } = useNuxtApp();
|
||||
const { $empty, $copy, $patchapi, $insertapi, $findIndex, $snackbar } = useNuxtApp();
|
||||
const radioOption = ref();
|
||||
const login = { id: 1 };
|
||||
const errors = ref([]);
|
||||
|
||||
@@ -3,7 +3,7 @@ const props = defineProps({
|
||||
variant: Object,
|
||||
});
|
||||
|
||||
const { $empty, $insertapi } = useNuxtApp();
|
||||
const { $insertapi } = useNuxtApp();
|
||||
const emit = defineEmits(["created"]);
|
||||
const isLoading = ref(false);
|
||||
const body = ref({
|
||||
|
||||
@@ -5,7 +5,7 @@ import { isEqual, omitBy } from "es-toolkit";
|
||||
|
||||
const emit = defineEmits(["created"]);
|
||||
|
||||
const { $buildFileUrl, $copy, $empty, $getdata, $insertapi, $patchapi } = useNuxtApp();
|
||||
const { $buildFileUrl, $copy, $empty, $insertapi } = useNuxtApp();
|
||||
const isPending = ref(false);
|
||||
const defaultBody = ref({
|
||||
product: null,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup>
|
||||
const { $empty, $insertapi } = useNuxtApp();
|
||||
const { $insertapi } = useNuxtApp();
|
||||
const emit = defineEmits(["modalevent"]);
|
||||
|
||||
const isLoading = ref(false);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup>
|
||||
const { $empty, $insertapi } = useNuxtApp();
|
||||
const { $insertapi } = useNuxtApp();
|
||||
const emit = defineEmits(["modalevent"]);
|
||||
|
||||
const isLoading = ref(false);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup>
|
||||
const { $empty, $insertapi } = useNuxtApp();
|
||||
const { $insertapi } = useNuxtApp();
|
||||
const emit = defineEmits(["modalevent"]);
|
||||
|
||||
const isLoading = ref(false);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup>
|
||||
const { $empty, $insertapi } = useNuxtApp();
|
||||
const { $insertapi } = useNuxtApp();
|
||||
const emit = defineEmits(["modalevent"]);
|
||||
|
||||
const isLoading = ref(false);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup>
|
||||
const { $empty, $insertapi } = useNuxtApp();
|
||||
const { $insertapi } = useNuxtApp();
|
||||
const emit = defineEmits(["modalevent"]);
|
||||
|
||||
const isLoading = ref(false);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup>
|
||||
const { $empty, $insertapi } = useNuxtApp();
|
||||
const { $insertapi } = useNuxtApp();
|
||||
const emit = defineEmits(["modalevent"]);
|
||||
|
||||
const isLoading = ref(false);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup>
|
||||
const { $empty, $insertapi } = useNuxtApp();
|
||||
const { $insertapi } = useNuxtApp();
|
||||
const emit = defineEmits(["modalevent"]);
|
||||
|
||||
const isLoading = ref(false);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup>
|
||||
const { $empty, $insertapi } = useNuxtApp();
|
||||
const { $insertapi } = useNuxtApp();
|
||||
const emit = defineEmits(["modalevent"]);
|
||||
|
||||
const isLoading = ref(false);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup>
|
||||
const { $empty, $insertapi } = useNuxtApp();
|
||||
const { $insertapi } = useNuxtApp();
|
||||
const emit = defineEmits(["modalevent"]);
|
||||
|
||||
const isLoading = ref(false);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script setup>
|
||||
import InputNumber from "~/components/common/InputNumber.vue";
|
||||
|
||||
const { $empty, $insertapi } = useNuxtApp();
|
||||
const { $insertapi } = useNuxtApp();
|
||||
const emit = defineEmits(["modalevent"]);
|
||||
|
||||
const isLoading = ref(false);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup>
|
||||
const { $empty, $insertapi } = useNuxtApp();
|
||||
const { $insertapi } = useNuxtApp();
|
||||
const emit = defineEmits(["modalevent"]);
|
||||
|
||||
const isLoading = ref(false);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup>
|
||||
const { $empty, $insertapi } = useNuxtApp();
|
||||
const { $insertapi } = useNuxtApp();
|
||||
const emit = defineEmits(["modalevent"]);
|
||||
|
||||
const isLoading = ref(false);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup>
|
||||
const { $empty, $insertapi } = useNuxtApp();
|
||||
const { $insertapi } = useNuxtApp();
|
||||
const emit = defineEmits(["modalevent"]);
|
||||
|
||||
const isLoading = ref(false);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script setup>
|
||||
import InputNumber from "~/components/common/InputNumber.vue";
|
||||
|
||||
const { $empty, $insertapi } = useNuxtApp();
|
||||
const { $insertapi } = useNuxtApp();
|
||||
const emit = defineEmits(["modalevent"]);
|
||||
|
||||
const isLoading = ref(false);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script setup>
|
||||
import InputNumber from "~/components/common/InputNumber.vue";
|
||||
|
||||
const { $empty, $insertapi } = useNuxtApp();
|
||||
const { $insertapi } = useNuxtApp();
|
||||
const emit = defineEmits(["modalevent"]);
|
||||
|
||||
const isLoading = ref(false);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup>
|
||||
const { $empty, $insertapi } = useNuxtApp();
|
||||
const { $insertapi } = useNuxtApp();
|
||||
const emit = defineEmits(["modalevent"]);
|
||||
|
||||
const isLoading = ref(false);
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
import InventoryHighlightCard from "~/components/inventory/InventoryHighlightCard.vue";
|
||||
import InventoryTable from "~/components/inventory/InventoryTable.vue";
|
||||
|
||||
const { $store } = useNuxtApp();
|
||||
const inventoryHighlights = [
|
||||
{
|
||||
name: "Tổng số SKU",
|
||||
|
||||
@@ -5,7 +5,6 @@ const props = defineProps({
|
||||
});
|
||||
|
||||
const emit = defineEmits(["selectInvItem", "unselect"]);
|
||||
const { $dayjs } = useNuxtApp();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
@@ -2,9 +2,6 @@
|
||||
const props = defineProps({
|
||||
invItem: Object,
|
||||
});
|
||||
|
||||
const { $dayjs, $formatNum } = useNuxtApp();
|
||||
const emit = defineEmits("unselect");
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -14,7 +11,7 @@ const emit = defineEmits("unselect");
|
||||
>
|
||||
<div class="card">
|
||||
<button
|
||||
@click="emit('unselect')"
|
||||
@click="$emit('unselect')"
|
||||
class="button is-white rounded-full has-text-grey absolute size-8 is-flex is-justify-content-center is-align-items-center"
|
||||
style="z-index: 1; right: 0.5rem; top: 0.5rem"
|
||||
>
|
||||
|
||||
@@ -191,15 +191,12 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { useNuxtApp } from "nuxt/app";
|
||||
import { ref, computed, onMounted, watch, markRaw } from "vue";
|
||||
import EmailForm1 from "./forms/EmailForm1.vue";
|
||||
import Template1 from "~/components/marketing/email/Template1.vue";
|
||||
import Modal from "~/components/Modal.vue";
|
||||
import MappingConfigurator from "~/components/marketing/email/MappingConfigurator.vue";
|
||||
import JobConfigurator from "~/components/marketing/email/JobConfigurator.vue";
|
||||
|
||||
const nuxtApp = useNuxtApp();
|
||||
const { $getdata, $snackbar, $deleteapi, $getEditRights } = useNuxtApp();
|
||||
const showmodal = ref();
|
||||
const activeTab = ref("content");
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
<script setup>
|
||||
const { $buildFileUrl, $copyToClipboard } = useNuxtApp();
|
||||
|
||||
const props = defineProps({
|
||||
className: String,
|
||||
image: Object,
|
||||
@@ -8,14 +6,12 @@ const props = defineProps({
|
||||
downloadImage: Function,
|
||||
openDeleteImageConfirm: Function,
|
||||
});
|
||||
|
||||
const url = $buildFileUrl(props.image.file__file);
|
||||
</script>
|
||||
<template>
|
||||
<div :class="['buttons has-addons', className]">
|
||||
<button
|
||||
class="button is-small is-white"
|
||||
@click="$copyToClipboard(url)"
|
||||
@click="$copyToClipboard($buildFileUrl(props.image.file__file))"
|
||||
title="Sao chép link"
|
||||
>
|
||||
<span class="icon">
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
/>
|
||||
</template>
|
||||
<script setup>
|
||||
const { $copy, $getpath, $download } = useNuxtApp();
|
||||
const { $copy, $getpath } = useNuxtApp();
|
||||
const emit = defineEmits(["remove", "close"]);
|
||||
const props = defineProps({
|
||||
files: Object,
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
class="file-input"
|
||||
ref="file-input"
|
||||
type="file"
|
||||
:id="docid"
|
||||
:id="$id()"
|
||||
:multiple="multiple ?? true"
|
||||
name="resume"
|
||||
@change="doChange"
|
||||
@@ -52,14 +52,13 @@ const props = defineProps({
|
||||
});
|
||||
|
||||
const emit = defineEmits(["files"]);
|
||||
const { $id, $snackbar, $upload } = useNuxtApp();
|
||||
const { $snackbar, $upload } = useNuxtApp();
|
||||
|
||||
const fileInput = useTemplateRef("file-input");
|
||||
const vtype = props.type || ["image"];
|
||||
const files = ref(); // files selected in <input>
|
||||
const dataFiles = ref(); // files returned by $upload
|
||||
const showmodal = ref();
|
||||
const docid = $id();
|
||||
|
||||
function getFileExtension(fileName) {
|
||||
if (!fileName || typeof fileName !== "string") return "";
|
||||
|
||||
@@ -10,7 +10,7 @@ const props = defineProps({
|
||||
viewImage: Function,
|
||||
});
|
||||
|
||||
const { $buildFileUrl, $formatFileSize, $getpath, $patchapi, $snackbar } = useNuxtApp();
|
||||
const { $buildFileUrl, $getpath, $patchapi, $snackbar } = useNuxtApp();
|
||||
|
||||
const url = $buildFileUrl(props.image.file__file);
|
||||
|
||||
|
||||
@@ -201,9 +201,7 @@
|
||||
/>
|
||||
</template>
|
||||
<script setup>
|
||||
import { ref } from "vue";
|
||||
import { debounce } from "es-toolkit";
|
||||
import { useNuxtApp } from "#app";
|
||||
import FileUpload from "~/components/media/FileUpload.vue";
|
||||
import ImageCard from "~/components/media/ImageCard.vue";
|
||||
|
||||
|
||||
@@ -3,8 +3,6 @@ const props = defineProps({
|
||||
invoice: Object,
|
||||
});
|
||||
|
||||
const { $dayjs } = useNuxtApp();
|
||||
|
||||
const historyItems = [
|
||||
{
|
||||
id: 1,
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
const props = defineProps({
|
||||
invoice: Object,
|
||||
});
|
||||
const { $formatNum } = useNuxtApp();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
@@ -5,7 +5,7 @@ const props = defineProps({
|
||||
invoice: Object,
|
||||
});
|
||||
|
||||
const { $getdata, $formatNum } = useNuxtApp();
|
||||
const { $getdata } = useNuxtApp();
|
||||
const invoiceDetails = ref([]);
|
||||
onMounted(async () => {
|
||||
invoiceDetails.value = await $getdata("Invoice_Detail", { filter: { invoice: props.invoice.id } });
|
||||
|
||||
@@ -9,7 +9,6 @@ const props = defineProps({
|
||||
invoice: Object,
|
||||
});
|
||||
|
||||
const { $dayjs, $formatNum } = useNuxtApp();
|
||||
const emit = defineEmits(["unselect"]);
|
||||
|
||||
const tabs = [
|
||||
|
||||
@@ -164,7 +164,7 @@
|
||||
</button>
|
||||
<button
|
||||
class="button is-light has-text-black"
|
||||
@click="exportPdf(docid, { filename: record.code })"
|
||||
@click="$exportPdf(docid, { filename: record.code })"
|
||||
>
|
||||
{{ findLang("print") }}
|
||||
</button>
|
||||
|
||||
@@ -4,7 +4,7 @@ const props = defineProps({
|
||||
deleteable: Boolean,
|
||||
invalid: Boolean,
|
||||
});
|
||||
const { $deleteapi, $formatNum, $snackbar } = useNuxtApp();
|
||||
const { $deleteapi, $snackbar } = useNuxtApp();
|
||||
const posStore = usePosStore();
|
||||
const showConfirmModal = ref();
|
||||
const isDeleting = ref(false);
|
||||
|
||||
@@ -7,7 +7,7 @@ import useOrderInfo from "~/components/pos/composables/useOrderInfo";
|
||||
import SearchBox from "~/components/SearchBox.vue";
|
||||
|
||||
const store = useStore();
|
||||
const { $insertapi, $formatNum } = useNuxtApp();
|
||||
const { $insertapi } = useNuxtApp();
|
||||
|
||||
const posStore = usePosStore();
|
||||
const { carts, isPending, activeCartId, invalidCartItems, addresses, orderInfo } = storeToRefs(posStore);
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
<script setup>
|
||||
import useOrderInfo from "~/components/pos/composables/useOrderInfo";
|
||||
|
||||
const props = defineProps({
|
||||
invoiceId: Number,
|
||||
finalizeOrder: Function,
|
||||
});
|
||||
const { activeCartItems } = useActiveCart();
|
||||
const subtotal = computed(() => {
|
||||
return activeCartItems.value?.reduce((prev, curr) => prev + curr.imei__variant__price, 0);
|
||||
});
|
||||
const { total } = useOrderInfo();
|
||||
</script>
|
||||
<template>
|
||||
<div class="is-flex is-flex-direction-column is-gap-2 is-align-items-center">
|
||||
<NuxtImg
|
||||
:src="qr(subtotal)"
|
||||
:src="$qr(total)"
|
||||
class="h-full max-h-140"
|
||||
alt="VietQR code"
|
||||
/>
|
||||
|
||||
@@ -19,6 +19,3 @@
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
const { $store, $requestLogin } = useNuxtApp();
|
||||
</script>
|
||||
|
||||
@@ -8,6 +8,9 @@ import isSameOrBefore from "dayjs/plugin/isSameOrBefore";
|
||||
import isSameOrAfter from "dayjs/plugin/isSameOrAfter";
|
||||
import "dayjs/locale/vi";
|
||||
import { deburr } from "es-toolkit";
|
||||
import html2pdf from "html2pdf.js";
|
||||
import html2canvas from "html2canvas-pro";
|
||||
|
||||
dayjs.extend(weekday);
|
||||
dayjs.extend(weekOfYear);
|
||||
dayjs.extend(relativeTime);
|
||||
@@ -19,7 +22,7 @@ dayjs.locale("vi");
|
||||
export default defineNuxtPlugin((nuxtApp) => {
|
||||
const route = useRoute();
|
||||
const store = useStore();
|
||||
const { $id, $empty } = nuxtApp;
|
||||
const { $id, $copy, $empty } = nuxtApp;
|
||||
|
||||
const dialog = function (content, title, type, duration, width, height, vbind) {
|
||||
content = typeof content === "string" ? content : JSON.stringify(content);
|
||||
@@ -98,7 +101,7 @@ export default defineNuxtPlugin((nuxtApp) => {
|
||||
};
|
||||
|
||||
const dummy = function (data, count) {
|
||||
let list = this.$copy(data);
|
||||
let list = $copy(data);
|
||||
for (let index = 0; index < count; index++) {
|
||||
if (data.length < index + 1) list.push({ dummy: true });
|
||||
}
|
||||
@@ -167,7 +170,7 @@ export default defineNuxtPlugin((nuxtApp) => {
|
||||
};
|
||||
|
||||
const change = function (obj1, obj2, list) {
|
||||
var change = false;
|
||||
let change = false;
|
||||
if (list) {
|
||||
list.map((v) => {
|
||||
if (obj1[v] !== obj2[v]) change = true;
|
||||
@@ -233,6 +236,65 @@ export default defineNuxtPlugin((nuxtApp) => {
|
||||
return id;
|
||||
};
|
||||
|
||||
const exportPdf = async (docid, { filename = "file", format = "a4", orientation = "portrait" } = {}) => {
|
||||
const target = document.getElementById(docid);
|
||||
|
||||
const ignored = target.querySelectorAll(".ignore");
|
||||
ignored.forEach((el) => el.style.setProperty("display", "none", "important"));
|
||||
// Xóa cache ảnh để lần export sau không bị lỗi
|
||||
target.querySelectorAll("img").forEach((img) => (img.src = `${img.src}`));
|
||||
const restoreIcons = swapIconsForExport(target);
|
||||
|
||||
const opt = {
|
||||
margin: 3,
|
||||
filename: `${filename}-${dayjs().format("YYYYMMDDHHmmss")}.pdf`,
|
||||
jsPDF: { format, orientation, unit: "mm" },
|
||||
html2canvas: { scale: 3, useCORS: true },
|
||||
image: { type: "jpeg", quality: 1 },
|
||||
pagebreak: {
|
||||
mode: ["avoid-all", "css", "legacy"],
|
||||
before: ".page-break-before",
|
||||
after: ".page-break-after",
|
||||
avoid: ".avoid-page-break",
|
||||
},
|
||||
};
|
||||
|
||||
try {
|
||||
await new Promise((r) => requestAnimationFrame(r));
|
||||
await html2pdf().set(opt).from(target).save();
|
||||
} finally {
|
||||
restoreIcons();
|
||||
ignored.forEach((el) => el.style.removeProperty("display"));
|
||||
}
|
||||
return opt.filename;
|
||||
};
|
||||
|
||||
const exportImage = async (docid, filename = "file") => {
|
||||
const target = document.getElementById(docid);
|
||||
|
||||
const ignored = target.querySelectorAll(".ignore");
|
||||
ignored.forEach((el) => el.style.setProperty("display", "none", "important"));
|
||||
// Xóa cache ảnh để lần export sau không bị lỗi
|
||||
target.querySelectorAll("img").forEach((img) => (img.src = `${img.src}`));
|
||||
const restoreIcons = swapIconsForExport(target);
|
||||
|
||||
try {
|
||||
await new Promise((r) => requestAnimationFrame(r));
|
||||
|
||||
const canvas = await html2canvas(target);
|
||||
const link = document.createElement("a");
|
||||
link.href = canvas.toDataURL("image/png");
|
||||
link.download = `${filename}-${dayjs().format("YYYYMMDDHHmmss")}.png`;
|
||||
link.click();
|
||||
link.remove();
|
||||
} finally {
|
||||
restoreIcons();
|
||||
ignored.forEach((el) => el.style.removeProperty("display"));
|
||||
}
|
||||
|
||||
return filename;
|
||||
};
|
||||
|
||||
const download = async function (url, fileName) {
|
||||
const name = dayjs(new Date()).format("YYYYMMDDhhmmss") + "-" + fileName;
|
||||
const response = await fetch(url);
|
||||
@@ -480,6 +542,27 @@ export default defineNuxtPlugin((nuxtApp) => {
|
||||
return new Intl.NumberFormat("en", { notation: "compact" }).format(Number(amount));
|
||||
}
|
||||
|
||||
function qr(amount, qrVars = {}) {
|
||||
const defaultQRVars = {
|
||||
bankId: "BIDV",
|
||||
accountNo: "1222198820",
|
||||
accountName: "Nguyen Viet An",
|
||||
template: "Rxp4lcv",
|
||||
description: "Thanh toan ERP",
|
||||
};
|
||||
|
||||
const finalVars = {
|
||||
...defaultQRVars,
|
||||
...qrVars,
|
||||
};
|
||||
|
||||
const { bankId, accountNo, template, description, accountName } = finalVars;
|
||||
|
||||
const qrSrc = `https://img.vietqr.io/image/${bankId}-${accountNo}-${template}.png?amount=${amount}&addInfo=${description}&accountName=${accountName}`;
|
||||
|
||||
return qrSrc;
|
||||
}
|
||||
|
||||
return {
|
||||
provide: {
|
||||
dialog,
|
||||
@@ -495,6 +578,8 @@ export default defineNuxtPlugin((nuxtApp) => {
|
||||
copyToClipboard,
|
||||
nonAccent,
|
||||
linkID,
|
||||
exportPdf,
|
||||
exportImage,
|
||||
vnmoney,
|
||||
createMeta,
|
||||
dayjs,
|
||||
@@ -504,6 +589,7 @@ export default defineNuxtPlugin((nuxtApp) => {
|
||||
numberToVietnamese,
|
||||
formatDateVN,
|
||||
shortenCurrency,
|
||||
qr,
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
import dayjs from "dayjs";
|
||||
import html2canvas from "html2canvas-pro";
|
||||
|
||||
export default async function exportImage(docid, filename = "file") {
|
||||
const target = document.getElementById(docid);
|
||||
|
||||
const ignored = target.querySelectorAll(".ignore");
|
||||
ignored.forEach((el) => el.style.setProperty("display", "none", "important"));
|
||||
// Xóa cache ảnh để lần export sau không bị lỗi
|
||||
target.querySelectorAll("img").forEach((img) => (img.src = `${img.src}`));
|
||||
const restoreIcons = swapIconsForExport(target);
|
||||
|
||||
try {
|
||||
await new Promise((r) => requestAnimationFrame(r));
|
||||
|
||||
const canvas = await html2canvas(target);
|
||||
const link = document.createElement("a");
|
||||
link.href = canvas.toDataURL("image/png");
|
||||
link.download = `${filename}-${dayjs().format("YYYYMMDDHHmmss")}.png`;
|
||||
link.click();
|
||||
link.remove();
|
||||
} finally {
|
||||
restoreIcons();
|
||||
ignored.forEach((el) => el.style.removeProperty("display"));
|
||||
}
|
||||
|
||||
return filename;
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
import dayjs from "dayjs";
|
||||
import html2pdf from "html2pdf.js";
|
||||
|
||||
export default async function exportPdf(docid, { filename = "file", format = "a4", orientation = "portrait" } = {}) {
|
||||
const target = document.getElementById(docid);
|
||||
|
||||
const ignored = target.querySelectorAll(".ignore");
|
||||
ignored.forEach((el) => el.style.setProperty("display", "none", "important"));
|
||||
// Xóa cache ảnh để lần export sau không bị lỗi
|
||||
target.querySelectorAll("img").forEach((img) => (img.src = `${img.src}`));
|
||||
const restoreIcons = swapIconsForExport(target);
|
||||
|
||||
const opt = {
|
||||
margin: 3,
|
||||
filename: `${filename}-${dayjs().format("YYYYMMDDHHmmss")}.pdf`,
|
||||
jsPDF: { format, orientation, unit: "mm" },
|
||||
html2canvas: { scale: 3, useCORS: true },
|
||||
image: { type: "jpeg", quality: 1 },
|
||||
pagebreak: {
|
||||
mode: ["avoid-all", "css", "legacy"],
|
||||
before: ".page-break-before",
|
||||
after: ".page-break-after",
|
||||
avoid: ".avoid-page-break",
|
||||
},
|
||||
};
|
||||
|
||||
try {
|
||||
await new Promise((r) => requestAnimationFrame(r));
|
||||
await html2pdf().set(opt).from(target).save();
|
||||
} finally {
|
||||
restoreIcons();
|
||||
ignored.forEach((el) => el.style.removeProperty("display"));
|
||||
}
|
||||
return opt.filename;
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
export default function qr(amount, qrVars = {}) {
|
||||
const defaultQRVars = {
|
||||
bankId: "BIDV",
|
||||
accountNo: "1222198820",
|
||||
accountName: "Nguyen Viet An",
|
||||
template: "Rxp4lcv",
|
||||
description: "Thanh toan ERP",
|
||||
};
|
||||
|
||||
const finalVars = {
|
||||
...defaultQRVars,
|
||||
...qrVars,
|
||||
};
|
||||
|
||||
const { bankId, accountNo, template, description, accountName } = finalVars;
|
||||
|
||||
const qrSrc = `https://img.vietqr.io/image/${bankId}-${accountNo}-${template}.png?amount=${amount}&addInfo=${description}&accountName=${accountName}`;
|
||||
|
||||
return qrSrc;
|
||||
}
|
||||
Reference in New Issue
Block a user