changes
This commit is contained in:
@@ -1,10 +0,0 @@
|
|||||||
<script setup>
|
|
||||||
const { $empty, $numtoString } = useNuxtApp();
|
|
||||||
const props = defineProps({
|
|
||||||
value: Number,
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<span>{{ $empty(value) ? "-" : $numtoString(value) }}</span>
|
|
||||||
</template>
|
|
||||||
@@ -37,10 +37,10 @@ export default {
|
|||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
if (this.defaultValue) {
|
if (this.defaultValue) {
|
||||||
this.value = this.value !== undefined ? this.$numtoString(this.value) : this.$numtoString(0);
|
this.value = this.value !== undefined ? this.$formatNum(this.value) : this.$formatNum(0);
|
||||||
} else {
|
} else {
|
||||||
if (this.value !== undefined && this.value !== null) {
|
if (this.value !== undefined && this.value !== null) {
|
||||||
this.value = this.$numtoString(this.value);
|
this.value = this.$formatNum(this.value);
|
||||||
} else {
|
} else {
|
||||||
this.value = "";
|
this.value = "";
|
||||||
}
|
}
|
||||||
@@ -48,7 +48,7 @@ export default {
|
|||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
record() {
|
record() {
|
||||||
this.value = this.$numtoString(this.record[this.attr]);
|
this.value = this.$formatNum(this.record[this.attr]);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -71,14 +71,14 @@ export default {
|
|||||||
getDisplayValue(recordValue) {
|
getDisplayValue(recordValue) {
|
||||||
if (this.defaultValue) {
|
if (this.defaultValue) {
|
||||||
if (recordValue === null || recordValue === undefined || recordValue === "") {
|
if (recordValue === null || recordValue === undefined || recordValue === "") {
|
||||||
return this.$numtoString(0);
|
return this.$formatNum(0);
|
||||||
}
|
}
|
||||||
return this.$numtoString(recordValue);
|
return this.$formatNum(recordValue);
|
||||||
} else {
|
} else {
|
||||||
if (recordValue === null || recordValue === undefined || recordValue === "") {
|
if (recordValue === null || recordValue === undefined || recordValue === "") {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return this.$numtoString(recordValue);
|
return this.$formatNum(recordValue);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
doCheck() {
|
doCheck() {
|
||||||
@@ -90,11 +90,11 @@ export default {
|
|||||||
},
|
},
|
||||||
checkChange() {
|
checkChange() {
|
||||||
if (!this.$empty(this.value)) {
|
if (!this.$empty(this.value)) {
|
||||||
this.value = this.$numtoString(this.$formatNumber(this.value));
|
this.value = this.$formatNum(this.$parseNum(this.value));
|
||||||
this.$emit("number", this.$formatNumber(this.value));
|
this.$emit("number", this.$parseNum(this.value));
|
||||||
} else {
|
} else {
|
||||||
if (this.defaultValue) {
|
if (this.defaultValue) {
|
||||||
this.value = this.$numtoString(0);
|
this.value = this.$formatNum(0);
|
||||||
this.$emit("number", 0);
|
this.$emit("number", 0);
|
||||||
} else {
|
} else {
|
||||||
this.value = "";
|
this.value = "";
|
||||||
|
|||||||
@@ -462,31 +462,31 @@ const getMenu = function () {
|
|||||||
};
|
};
|
||||||
var selectTab = getMenu()[0];
|
var selectTab = getMenu()[0];
|
||||||
var datatype = store.datatype;
|
var datatype = store.datatype;
|
||||||
var current = 1;
|
// var current = 1;
|
||||||
var value1 = undefined;
|
// var value1 = undefined;
|
||||||
var value2 = undefined;
|
// var value2 = undefined;
|
||||||
const moneyunit = store.moneyunit;
|
const moneyunit = store.moneyunit;
|
||||||
const radioType = store.datatype.find((v) => v.code === currentField.format);
|
const radioType = store.datatype.find((v) => v.code === currentField.format);
|
||||||
var selectUnit = currentField.format === "number" ? moneyunit.find((v) => v.detail === currentField.unit) : undefined;
|
// var selectUnit = currentField.format === "number" ? moneyunit.find((v) => v.detail === currentField.unit) : undefined;
|
||||||
var bgcolor = undefined;
|
// var bgcolor = undefined;
|
||||||
var radioBGcolor = colorchoice.find((v) => v.code === "none");
|
// var radioBGcolor = colorchoice.find((v) => v.code === "none");
|
||||||
var color = undefined;
|
// var color = undefined;
|
||||||
var radioColor = colorchoice.find((v) => v.code === "none");
|
// var radioColor = colorchoice.find((v) => v.code === "none");
|
||||||
var textsize = undefined;
|
// var textsize = undefined;
|
||||||
var radioSize = colorchoice.find((v) => v.code === "none");
|
// var radioSize = colorchoice.find((v) => v.code === "none");
|
||||||
var minwidth = undefined;
|
var minwidth = undefined;
|
||||||
var radioWidth = colorchoice.find((v) => v.code === "none");
|
// var radioWidth = colorchoice.find((v) => v.code === "none");
|
||||||
var radioMaxWidth = colorchoice.find((v) => v.code === "none");
|
// var radioMaxWidth = colorchoice.find((v) => v.code === "none");
|
||||||
var maxwidth = undefined;
|
var maxwidth = undefined;
|
||||||
var selectAlign = undefined;
|
// var selectAlign = undefined;
|
||||||
var radioAlign = colorchoice.find((v) => v.code === "none");
|
// var radioAlign = colorchoice.find((v) => v.code === "none");
|
||||||
var radioTemplate = ref(colorchoice.find((v) => v.code === (currentField.template ? "option" : "none"))["code"]);
|
var radioTemplate = ref(colorchoice.find((v) => v.code === (currentField.template ? "option" : "none"))["code"]);
|
||||||
var selectPlacement = store.placement.find((v) => v.code === "is-right");
|
// var selectPlacement = store.placement.find((v) => v.code === "is-right");
|
||||||
var selectScheme = store.colorscheme.find((v) => v.code === "is-primary");
|
// var selectScheme = store.colorscheme.find((v) => v.code === "is-primary");
|
||||||
var radioTooltip = store.colorchoice.find((v) => v.code === "none");
|
// var radioTooltip = store.colorchoice.find((v) => v.code === "none");
|
||||||
var selectField = undefined;
|
// var selectField = undefined;
|
||||||
var tags = currentField.tags ? currentField.tags.map((v) => fields.find((x) => x.name === v)) : [];
|
// var tags = currentField.tags ? currentField.tags.map((v) => fields.find((x) => x.name === v)) : [];
|
||||||
var formula = currentField.formula ? currentField.formula : undefined;
|
// var formula = currentField.formula ? currentField.formula : undefined;
|
||||||
var decimal = currentField.decimal;
|
var decimal = currentField.decimal;
|
||||||
let shortmenu = store.menuchoice.filter((x) =>
|
let shortmenu = store.menuchoice.filter((x) =>
|
||||||
currentField.format === "number"
|
currentField.format === "number"
|
||||||
|
|||||||
@@ -615,7 +615,7 @@ const checkExpression = function () {
|
|||||||
tagsField.forEach((v) => {
|
tagsField.forEach((v) => {
|
||||||
let myRegExp = new RegExp(v.name, "g");
|
let myRegExp = new RegExp(v.name, "g");
|
||||||
val = val.replace(myRegExp, Math.random());
|
val = val.replace(myRegExp, Math.random());
|
||||||
exp = exp.replace(myRegExp, "formatNumber(row['" + v.name + "'])");
|
exp = exp.replace(myRegExp, "parseNum(row['" + v.name + "'])");
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
let value = $calc(val);
|
let value = $calc(val);
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ const {
|
|||||||
$empty,
|
$empty,
|
||||||
$find,
|
$find,
|
||||||
$getEditRights,
|
$getEditRights,
|
||||||
$formatNumber,
|
$parseNum,
|
||||||
$multiSort,
|
$multiSort,
|
||||||
$remove,
|
$remove,
|
||||||
$stripHtml,
|
$stripHtml,
|
||||||
@@ -420,8 +420,8 @@ const frontendFilter = function (newVal) {
|
|||||||
else {
|
else {
|
||||||
let text = "";
|
let text = "";
|
||||||
filter.map((y, k) => {
|
filter.map((y, k) => {
|
||||||
text += `${k > 0 ? (filter[k - 1].operator === "and" ? " &&" : " ||") : ""} ${$formatNumber(x[name])}
|
text += `${k > 0 ? (filter[k - 1].operator === "and" ? " &&" : " ||") : ""} ${$parseNum(x[name])}
|
||||||
${y.condition === "=" ? "==" : y.condition === "<>" ? "!==" : y.condition} ${$formatNumber(y.value)}`;
|
${y.condition === "=" ? "==" : y.condition === "<>" ? "!==" : y.condition} ${$parseNum(y.value)}`;
|
||||||
});
|
});
|
||||||
return $calc(text);
|
return $calc(text);
|
||||||
}
|
}
|
||||||
@@ -541,7 +541,7 @@ const updateData = async function (newVal) {
|
|||||||
}
|
}
|
||||||
if (newVal.tablesetting) {
|
if (newVal.tablesetting) {
|
||||||
tablesetting = newVal.tablesetting;
|
tablesetting = newVal.tablesetting;
|
||||||
perPage = $formatNumber(tablesetting.find((v) => v.code == "per-page").detail);
|
perPage = $parseNum(tablesetting.find((v) => v.code == "per-page").detail);
|
||||||
currentPage = 1;
|
currentPage = 1;
|
||||||
}
|
}
|
||||||
tablesetting = $copy(pagedata.tablesetting || gridsetting);
|
tablesetting = $copy(pagedata.tablesetting || gridsetting);
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ export default {
|
|||||||
this.tagsField.forEach((v) => {
|
this.tagsField.forEach((v) => {
|
||||||
let myRegExp = new RegExp(v.name, "g");
|
let myRegExp = new RegExp(v.name, "g");
|
||||||
val = val.replace(myRegExp, Math.random());
|
val = val.replace(myRegExp, Math.random());
|
||||||
exp = exp.replace(myRegExp, "field.formatNumber(row['" + v.name + "'])");
|
exp = exp.replace(myRegExp, "field.parseNum(row['" + v.name + "'])");
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
let value = this.$calc(val);
|
let value = this.$calc(val);
|
||||||
|
|||||||
@@ -221,8 +221,8 @@ const {
|
|||||||
$stripHtml,
|
$stripHtml,
|
||||||
$snackbar,
|
$snackbar,
|
||||||
$dayjs,
|
$dayjs,
|
||||||
$formatNumber,
|
$parseNum,
|
||||||
$numtoString,
|
$formatNum,
|
||||||
$empty,
|
$empty,
|
||||||
$unique,
|
$unique,
|
||||||
$multiSort,
|
$multiSort,
|
||||||
@@ -523,9 +523,9 @@ const formatCellValue = (value, field) => {
|
|||||||
if (value === undefined || value === null || value === "") return "-";
|
if (value === undefined || value === null || value === "") return "-";
|
||||||
|
|
||||||
if (field.format === "number") {
|
if (field.format === "number") {
|
||||||
const num = $formatNumber(value);
|
const num = $parseNum(value);
|
||||||
if (num === undefined) return "-";
|
if (num === undefined) return "-";
|
||||||
return $numtoString(num, "vi-VN", field.decimal || 0, field.decimal || 0);
|
return $formatNum(num, "vi-VN", field.decimal || 0, field.decimal || 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (field.format === "date") {
|
if (field.format === "date") {
|
||||||
@@ -596,8 +596,8 @@ const getDataCellStyle = (row, leaf) => {
|
|||||||
|
|
||||||
if (cell && leaf.field) {
|
if (cell && leaf.field) {
|
||||||
if (leaf.field === "paid_amount") {
|
if (leaf.field === "paid_amount") {
|
||||||
const amount = $formatNumber(cell.amount) || 0;
|
const amount = $parseNum(cell.amount) || 0;
|
||||||
const paid = $formatNumber(cell.paid_amount) || 0;
|
const paid = $parseNum(cell.paid_amount) || 0;
|
||||||
if (paid >= amount) {
|
if (paid >= amount) {
|
||||||
style += " background-color: #d4edda;";
|
style += " background-color: #d4edda;";
|
||||||
} else if (paid > 0) {
|
} else if (paid > 0) {
|
||||||
@@ -608,8 +608,8 @@ const getDataCellStyle = (row, leaf) => {
|
|||||||
}
|
}
|
||||||
if (leaf.field === "to_date") {
|
if (leaf.field === "to_date") {
|
||||||
const dueDate = cell.to_date;
|
const dueDate = cell.to_date;
|
||||||
const paid = $formatNumber(cell.paid_amount) || 0;
|
const paid = $parseNum(cell.paid_amount) || 0;
|
||||||
const amount = $formatNumber(cell.amount) || 0;
|
const amount = $parseNum(cell.amount) || 0;
|
||||||
if (dueDate && paid < amount) {
|
if (dueDate && paid < amount) {
|
||||||
const today = new Date();
|
const today = new Date();
|
||||||
const due = new Date(dueDate);
|
const due = new Date(dueDate);
|
||||||
|
|||||||
@@ -433,7 +433,7 @@ export default {
|
|||||||
checkTimeopt() {
|
checkTimeopt() {
|
||||||
if (this.timeopt > 0) {
|
if (this.timeopt > 0) {
|
||||||
let obj = this.$find(this.options, {
|
let obj = this.$find(this.options, {
|
||||||
code: this.$formatNumber(this.timeopt),
|
code: this.$parseNum(this.timeopt),
|
||||||
});
|
});
|
||||||
if (obj) this.current = obj.code;
|
if (obj) this.current = obj.code;
|
||||||
}
|
}
|
||||||
@@ -442,7 +442,7 @@ export default {
|
|||||||
if (this.timeopt.disable.indexOf("time") >= 0) this.enableTime = false;
|
if (this.timeopt.disable.indexOf("time") >= 0) this.enableTime = false;
|
||||||
if (this.timeopt.time) {
|
if (this.timeopt.time) {
|
||||||
let obj = this.$find(this.options, {
|
let obj = this.$find(this.options, {
|
||||||
code: this.$formatNumber(this.timeopt.time),
|
code: this.$parseNum(this.timeopt.time),
|
||||||
});
|
});
|
||||||
if (obj) this.current = obj.code;
|
if (obj) this.current = obj.code;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ const props = defineProps({
|
|||||||
invItem: Object,
|
invItem: Object,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { $dayjs, $numtoString } = useNuxtApp();
|
const { $dayjs, $formatNum } = useNuxtApp();
|
||||||
const emit = defineEmits("unselect");
|
const emit = defineEmits("unselect");
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -54,13 +54,13 @@ const emit = defineEmits("unselect");
|
|||||||
<div class="px-4 py-3 is-flex-grow-1 rounded-md has-background-blue-95 has-text-blue-40">
|
<div class="px-4 py-3 is-flex-grow-1 rounded-md has-background-blue-95 has-text-blue-40">
|
||||||
<p class="fs-13">Giá đơn vị</p>
|
<p class="fs-13">Giá đơn vị</p>
|
||||||
<p class="fs-16 font-semibold">
|
<p class="fs-16 font-semibold">
|
||||||
{{ $numtoString(invItem.unit_price, { hasUnit: true }) }}
|
{{ $formatNum(invItem.unit_price, { hasUnit: true }) }}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="px-4 py-3 is-flex-grow-1 rounded-md has-background-purple-90 has-text-purple-40">
|
<div class="px-4 py-3 is-flex-grow-1 rounded-md has-background-purple-90 has-text-purple-40">
|
||||||
<p class="fs-13">Tổng giá trị</p>
|
<p class="fs-13">Tổng giá trị</p>
|
||||||
<p class="fs-16 font-semibold">
|
<p class="fs-16 font-semibold">
|
||||||
{{ $numtoString(invItem.total, { hasUnit: true }) }}
|
{{ $formatNum(invItem.total, { hasUnit: true }) }}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
invoice: Object,
|
invoice: Object,
|
||||||
});
|
});
|
||||||
const { $numtoString } = useNuxtApp();
|
const { $formatNum } = useNuxtApp();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -11,7 +11,7 @@ const { $numtoString } = useNuxtApp();
|
|||||||
<div class="is-flex-grow-1 p-3 rounded-md has-background-white-bis">
|
<div class="is-flex-grow-1 p-3 rounded-md has-background-white-bis">
|
||||||
<p class="fs-13 has-text-grey">Tổng tiền</p>
|
<p class="fs-13 has-text-grey">Tổng tiền</p>
|
||||||
<p class="font-bold">
|
<p class="font-bold">
|
||||||
{{ $numtoString(invoice.total, { hasUnit: true }) }}
|
{{ $formatNum(invoice.total, { hasUnit: true }) }}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="is-flex-grow-1 p-3 rounded-md has-background-success-95">
|
<div class="is-flex-grow-1 p-3 rounded-md has-background-success-95">
|
||||||
@@ -22,7 +22,7 @@ const { $numtoString } = useNuxtApp();
|
|||||||
<div class="p-4 mt-4 rounded-md has-background-danger-95">
|
<div class="p-4 mt-4 rounded-md has-background-danger-95">
|
||||||
<p class="fs-13 has-text-danger-50">Còn lại</p>
|
<p class="fs-13 has-text-danger-50">Còn lại</p>
|
||||||
<p class="fs-20 font-bold has-text-danger-40">
|
<p class="fs-20 font-bold has-text-danger-40">
|
||||||
{{ $numtoString(invoice.total, { hasUnit: true }) }}
|
{{ $formatNum(invoice.total, { hasUnit: true }) }}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ const props = defineProps({
|
|||||||
invoice: Object,
|
invoice: Object,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { $getdata, $numtoString } = useNuxtApp();
|
const { $getdata, $formatNum } = useNuxtApp();
|
||||||
const invoiceDetails = ref([]);
|
const invoiceDetails = ref([]);
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
invoiceDetails.value = await $getdata("Invoice_Detail", { filter: { invoice: props.invoice.id } });
|
invoiceDetails.value = await $getdata("Invoice_Detail", { filter: { invoice: props.invoice.id } });
|
||||||
@@ -22,12 +22,12 @@ onMounted(async () => {
|
|||||||
<div class="fs-15 is-flex is-justify-content-space-between">
|
<div class="fs-15 is-flex is-justify-content-space-between">
|
||||||
<p>{{ invoiceDetail.variant__product__name }}</p>
|
<p>{{ invoiceDetail.variant__product__name }}</p>
|
||||||
<p class="font-semibold">
|
<p class="font-semibold">
|
||||||
{{ $numtoString(invoiceDetail.price, { hasUnit: true }) }}
|
{{ $formatNum(invoiceDetail.price, { hasUnit: true }) }}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="is-flex is-gap-8 fs-13 has-text-grey-dark mt-1">
|
<div class="is-flex is-gap-8 fs-13 has-text-grey-dark mt-1">
|
||||||
<p>SL: {{ invoiceDetail.quantity }}</p>
|
<p>SL: {{ invoiceDetail.quantity }}</p>
|
||||||
<p>Đơn giá: {{ $numtoString(invoiceDetail.price, { hasUnit: true }) }}</p>
|
<p>Đơn giá: {{ $formatNum(invoiceDetail.price, { hasUnit: true }) }}</p>
|
||||||
<p>
|
<p>
|
||||||
Giảm:
|
Giảm:
|
||||||
{{ new Intl.NumberFormat("vi-VN", { style: "percent" }).format(invoiceDetail.discount) }}
|
{{ new Intl.NumberFormat("vi-VN", { style: "percent" }).format(invoiceDetail.discount) }}
|
||||||
@@ -40,19 +40,19 @@ onMounted(async () => {
|
|||||||
<tbody class="has-text-right">
|
<tbody class="has-text-right">
|
||||||
<tr>
|
<tr>
|
||||||
<td class="has-text-grey-dark">Tổng tiền hàng</td>
|
<td class="has-text-grey-dark">Tổng tiền hàng</td>
|
||||||
<td>{{ $numtoString(invoice.total_amount, { hasUnit: true }) }}</td>
|
<td>{{ $formatNum(invoice.total_amount, { hasUnit: true }) }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="has-text-grey-dark">Phí vận chuyển</td>
|
<td class="has-text-grey-dark">Phí vận chuyển</td>
|
||||||
<td>{{ $numtoString(invoice.shipping_fee, { hasUnit: true }) }}</td>
|
<td>{{ $formatNum(invoice.shipping_fee, { hasUnit: true }) }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="has-text-grey-dark">Giảm giá</td>
|
<td class="has-text-grey-dark">Giảm giá</td>
|
||||||
<td>{{ $numtoString(invoice.discount_amount, { hasUnit: true }) }}</td>
|
<td>{{ $formatNum(invoice.discount_amount, { hasUnit: true }) }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="font-bold">
|
<tr class="font-bold">
|
||||||
<td>Tổng cộng</td>
|
<td>Tổng cộng</td>
|
||||||
<td class="fs-17">{{ $numtoString(invoice.final_amount, { hasUnit: true }) }}</td>
|
<td class="fs-17">{{ $formatNum(invoice.final_amount, { hasUnit: true }) }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ const props = defineProps({
|
|||||||
invoice: Object,
|
invoice: Object,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { $dayjs, $numtoString } = useNuxtApp();
|
const { $dayjs, $formatNum } = useNuxtApp();
|
||||||
const emit = defineEmits(["unselect"]);
|
const emit = defineEmits(["unselect"]);
|
||||||
|
|
||||||
const tabs = [
|
const tabs = [
|
||||||
@@ -89,7 +89,7 @@ const activeTab = ref(tabs[0]);
|
|||||||
<div class="px-6 py-4 has-background-primary-95 rounded-lg mt-6">
|
<div class="px-6 py-4 has-background-primary-95 rounded-lg mt-6">
|
||||||
<p>Tổng giá trị đơn hàng</p>
|
<p>Tổng giá trị đơn hàng</p>
|
||||||
<p class="font-bold fs-25">
|
<p class="font-bold fs-25">
|
||||||
{{ $numtoString(invoice.total_amount, { hasUnit: true }) }}
|
{{ $formatNum(invoice.total_amount, { hasUnit: true }) }}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -286,7 +286,7 @@ export default {
|
|||||||
data.map((x) => {
|
data.map((x) => {
|
||||||
if (self.$empty(x[name])) x[name] = null;
|
if (self.$empty(x[name])) x[name] = null;
|
||||||
else {
|
else {
|
||||||
if (self.$isNumber(x[name])) x[name] = self.$formatNumber(x[name]);
|
if (self.$isNumber(x[name])) x[name] = self.$parseNum(x[name]);
|
||||||
else {
|
else {
|
||||||
x["error"] = `${name} không phải là số`;
|
x["error"] = `${name} không phải là số`;
|
||||||
error = true;
|
error = true;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ const props = defineProps({
|
|||||||
cartItem: Object,
|
cartItem: Object,
|
||||||
deleteable: Boolean,
|
deleteable: Boolean,
|
||||||
});
|
});
|
||||||
const { $deleteapi, $numtoString, $snackbar } = useNuxtApp();
|
const { $deleteapi, $formatNum, $snackbar } = useNuxtApp();
|
||||||
const { getCarts } = inject("pos");
|
const { getCarts } = inject("pos");
|
||||||
const showConfirmModal = ref();
|
const showConfirmModal = ref();
|
||||||
const isDeleting = ref(false);
|
const isDeleting = ref(false);
|
||||||
@@ -51,7 +51,7 @@ async function removeFromCart() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<p class="has-text-primary-50 font-medium">
|
<p class="has-text-primary-50 font-medium">
|
||||||
{{ $numtoString(cartItem.imei__variant__price, { hasUnit: true }) }}
|
{{ $formatNum(cartItem.imei__variant__price, { hasUnit: true }) }}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
|
|||||||
@@ -200,12 +200,12 @@ async function createOrder() {
|
|||||||
<span>Tạm tính</span>
|
<span>Tạm tính</span>
|
||||||
<span> ({{ activeCartItems.length }} sản phẩm)</span>
|
<span> ({{ activeCartItems.length }} sản phẩm)</span>
|
||||||
</td>
|
</td>
|
||||||
<td class="has-text-right">{{ $numtoString(subtotal, { hasUnit: true }) }}</td>
|
<td class="has-text-right">{{ $formatNum(subtotal, { hasUnit: true }) }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="font-bold fs-14">Tổng cộng</td>
|
<td class="font-bold fs-14">Tổng cộng</td>
|
||||||
<td class="has-text-right has-text-success-35 font-bold fs-17">
|
<td class="has-text-right has-text-success-35 font-bold fs-17">
|
||||||
{{ $numtoString(subtotal, { hasUnit: true }) }}
|
{{ $formatNum(subtotal, { hasUnit: true }) }}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import useOrderInfo from "~/components/pos/composables/useOrderInfo";
|
|||||||
import SearchBox from "~/components/SearchBox.vue";
|
import SearchBox from "~/components/SearchBox.vue";
|
||||||
|
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
const { $numtoString } = useNuxtApp();
|
const { $formatNum } = useNuxtApp();
|
||||||
|
|
||||||
const { carts, cartItems, customers, getCarts, isPending } = useCartData();
|
const { carts, cartItems, customers, getCarts, isPending } = useCartData();
|
||||||
|
|
||||||
@@ -313,12 +313,12 @@ provide("pos", {
|
|||||||
<span>Tạm tính</span>
|
<span>Tạm tính</span>
|
||||||
<span> ({{ activeCartItems?.length || 0 }} sản phẩm)</span>
|
<span> ({{ activeCartItems?.length || 0 }} sản phẩm)</span>
|
||||||
</td>
|
</td>
|
||||||
<td class="has-text-right">{{ $numtoString(subtotal, { hasUnit: true }) }}</td>
|
<td class="has-text-right">{{ $formatNum(subtotal, { hasUnit: true }) }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="font-bold fs-14">Tổng cộng</td>
|
<td class="font-bold fs-14">Tổng cộng</td>
|
||||||
<td class="has-text-right has-text-success-35 font-bold fs-17">
|
<td class="has-text-right has-text-success-35 font-bold fs-17">
|
||||||
{{ $numtoString(subtotal, { hasUnit: true }) }}
|
{{ $formatNum(subtotal, { hasUnit: true }) }}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -115,8 +115,8 @@ export default defineNuxtPlugin(() => {
|
|||||||
return !isNaN(val);
|
return !isNaN(val);
|
||||||
};
|
};
|
||||||
|
|
||||||
const numtoString = function (val, config = undefined) {
|
const formatNum = function (val, config = undefined) {
|
||||||
if (empty(val)) return "0";
|
if (empty(val)) return "-";
|
||||||
val = val.toString().replace(/,/g, "");
|
val = val.toString().replace(/,/g, "");
|
||||||
if (isNaN(val)) return;
|
if (isNaN(val)) return;
|
||||||
|
|
||||||
@@ -137,7 +137,7 @@ export default defineNuxtPlugin(() => {
|
|||||||
return Number(val).toLocaleString(type, typeof decimal === "number" ? options : undefined) + unit;
|
return Number(val).toLocaleString(type, typeof decimal === "number" ? options : undefined) + unit;
|
||||||
};
|
};
|
||||||
|
|
||||||
const formatNumber = function (val) {
|
const parseNum = function (val) {
|
||||||
if (empty(val)) return;
|
if (empty(val)) return;
|
||||||
val = val.toString().replace(/[,\.]/g, "");
|
val = val.toString().replace(/[,\.]/g, "");
|
||||||
if (val.indexOf("%") > 0) {
|
if (val.indexOf("%") > 0) {
|
||||||
@@ -148,7 +148,7 @@ export default defineNuxtPlugin(() => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const formatUnit = function (val, unit, decimal, string, mindecimal) {
|
const formatUnit = function (val, unit, decimal, string, mindecimal) {
|
||||||
val = formatNumber(val);
|
val = parseNum(val);
|
||||||
if (val === undefined) return;
|
if (val === undefined) return;
|
||||||
let percentage = unit === 0.01 || unit === "0.01" ? "%" : "";
|
let percentage = unit === 0.01 || unit === "0.01" ? "%" : "";
|
||||||
val = unit ? val / Number(unit) : val;
|
val = unit ? val / Number(unit) : val;
|
||||||
@@ -167,7 +167,7 @@ export default defineNuxtPlugin(() => {
|
|||||||
let valid = 0;
|
let valid = 0;
|
||||||
tags.forEach((v) => {
|
tags.forEach((v) => {
|
||||||
let myRegExp = new RegExp(v, "g");
|
let myRegExp = new RegExp(v, "g");
|
||||||
let res = this.$formatNumber(row[v]);
|
let res = this.$parseNum(row[v]);
|
||||||
if (res) valid = 1;
|
if (res) valid = 1;
|
||||||
val = val.replace(myRegExp, `(${res || 0})`);
|
val = val.replace(myRegExp, `(${res || 0})`);
|
||||||
});
|
});
|
||||||
@@ -190,7 +190,7 @@ export default defineNuxtPlugin(() => {
|
|||||||
|
|
||||||
const calculateFunc = function (row, cols, func, decimal, unit) {
|
const calculateFunc = function (row, cols, func, decimal, unit) {
|
||||||
let value;
|
let value;
|
||||||
let arr1 = cols.map((v) => this.$formatNumber(row[v]));
|
let arr1 = cols.map((v) => this.$parseNum(row[v]));
|
||||||
let arr = arr1.filter((v) => v);
|
let arr = arr1.filter((v) => v);
|
||||||
if (arr.length === 0) return { success: false, value: undefined };
|
if (arr.length === 0) return { success: false, value: undefined };
|
||||||
if (func === "max") value = Math.max(...arr);
|
if (func === "max") value = Math.max(...arr);
|
||||||
@@ -322,8 +322,8 @@ export default defineNuxtPlugin(() => {
|
|||||||
const key = sortKeys[index];
|
const key = sortKeys[index];
|
||||||
if (key) {
|
if (key) {
|
||||||
const direction = sortObject[key];
|
const direction = sortObject[key];
|
||||||
let val1 = format[key] === "number" ? (empty(a[key]) ? 0 : this.$formatNumber(a[key])) : a[key];
|
let val1 = format[key] === "number" ? (empty(a[key]) ? 0 : this.$parseNum(a[key])) : a[key];
|
||||||
let val2 = format[key] === "number" ? (empty(b[key]) ? 0 : this.$formatNumber(b[key])) : b[key];
|
let val2 = format[key] === "number" ? (empty(b[key]) ? 0 : this.$parseNum(b[key])) : b[key];
|
||||||
sorted = keySort(val1, val2, direction);
|
sorted = keySort(val1, val2, direction);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
@@ -447,8 +447,8 @@ export default defineNuxtPlugin(() => {
|
|||||||
remove,
|
remove,
|
||||||
stripHtml,
|
stripHtml,
|
||||||
isNumber,
|
isNumber,
|
||||||
numtoString,
|
formatNum,
|
||||||
formatNumber,
|
parseNum,
|
||||||
formatUnit,
|
formatUnit,
|
||||||
calc,
|
calc,
|
||||||
calculate,
|
calculate,
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import Email from "~/components/marketing/email/Email.vue";
|
|||||||
|
|
||||||
import Avatarbox from "~/components/common/Avatarbox.vue";
|
import Avatarbox from "~/components/common/Avatarbox.vue";
|
||||||
import CountdownTimer from "~/components/common/CountdownTimer.vue";
|
import CountdownTimer from "~/components/common/CountdownTimer.vue";
|
||||||
import FormatNumber from "~/components/common/FormatNumber.vue";
|
|
||||||
import FormatDate from "~/components/common/FormatDate.vue";
|
import FormatDate from "~/components/common/FormatDate.vue";
|
||||||
import InputNumber from "~/components/common/InputNumber.vue";
|
import InputNumber from "~/components/common/InputNumber.vue";
|
||||||
import CountWithAdd from "~/components/common/CountWithAdd.vue";
|
import CountWithAdd from "~/components/common/CountWithAdd.vue";
|
||||||
@@ -101,7 +100,6 @@ const components = {
|
|||||||
InputNumber,
|
InputNumber,
|
||||||
MenuPhone,
|
MenuPhone,
|
||||||
MenuParam,
|
MenuParam,
|
||||||
FormatNumber,
|
|
||||||
FormatDate,
|
FormatDate,
|
||||||
MenuAdd,
|
MenuAdd,
|
||||||
MenuNote,
|
MenuNote,
|
||||||
|
|||||||
Reference in New Issue
Block a user