From 87397be8bf274f7a12ac81dc5fd2f9119a33a1be Mon Sep 17 00:00:00 2001 From: Viet An Date: Thu, 18 Jun 2026 09:10:36 +0700 Subject: [PATCH] changes --- app/components/common/FormatNumber.vue | 10 ----- app/components/common/InputNumber.vue | 18 ++++----- app/components/datatable/ContextMenu.vue | 40 ++++++++++---------- app/components/datatable/CreateTemplate.vue | 2 +- app/components/datatable/DataTable.vue | 8 ++-- app/components/datatable/FilterOption.vue | 2 +- app/components/datatable/PivotDataView.vue | 16 ++++---- app/components/datatable/TimeOption.vue | 4 +- app/components/inventory/SelectedInvItem.vue | 6 +-- app/components/orders/OrderPaymentTab.vue | 6 +-- app/components/orders/OrderProductTab.vue | 14 +++---- app/components/orders/SelectedOrder.vue | 4 +- app/components/parameter/ImportData.vue | 2 +- app/components/pos/CartItem.vue | 4 +- app/components/pos/ConfirmOrder.vue | 4 +- app/components/pos/POS.vue | 6 +-- app/plugins/00-datatable.js | 20 +++++----- app/plugins/04-components.js | 2 - 18 files changed, 78 insertions(+), 90 deletions(-) delete mode 100644 app/components/common/FormatNumber.vue diff --git a/app/components/common/FormatNumber.vue b/app/components/common/FormatNumber.vue deleted file mode 100644 index 91515a2..0000000 --- a/app/components/common/FormatNumber.vue +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/app/components/common/InputNumber.vue b/app/components/common/InputNumber.vue index 0f65798..13b21d8 100644 --- a/app/components/common/InputNumber.vue +++ b/app/components/common/InputNumber.vue @@ -37,10 +37,10 @@ export default { }, created() { 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 { if (this.value !== undefined && this.value !== null) { - this.value = this.$numtoString(this.value); + this.value = this.$formatNum(this.value); } else { this.value = ""; } @@ -48,7 +48,7 @@ export default { }, watch: { record() { - this.value = this.$numtoString(this.record[this.attr]); + this.value = this.$formatNum(this.record[this.attr]); }, }, methods: { @@ -71,14 +71,14 @@ export default { getDisplayValue(recordValue) { if (this.defaultValue) { if (recordValue === null || recordValue === undefined || recordValue === "") { - return this.$numtoString(0); + return this.$formatNum(0); } - return this.$numtoString(recordValue); + return this.$formatNum(recordValue); } else { if (recordValue === null || recordValue === undefined || recordValue === "") { return ""; } - return this.$numtoString(recordValue); + return this.$formatNum(recordValue); } }, doCheck() { @@ -90,11 +90,11 @@ export default { }, checkChange() { if (!this.$empty(this.value)) { - this.value = this.$numtoString(this.$formatNumber(this.value)); - this.$emit("number", this.$formatNumber(this.value)); + this.value = this.$formatNum(this.$parseNum(this.value)); + this.$emit("number", this.$parseNum(this.value)); } else { if (this.defaultValue) { - this.value = this.$numtoString(0); + this.value = this.$formatNum(0); this.$emit("number", 0); } else { this.value = ""; diff --git a/app/components/datatable/ContextMenu.vue b/app/components/datatable/ContextMenu.vue index b790e0e..d8e7509 100644 --- a/app/components/datatable/ContextMenu.vue +++ b/app/components/datatable/ContextMenu.vue @@ -462,31 +462,31 @@ const getMenu = function () { }; var selectTab = getMenu()[0]; var datatype = store.datatype; -var current = 1; -var value1 = undefined; -var value2 = undefined; +// var current = 1; +// var value1 = undefined; +// var value2 = undefined; const moneyunit = store.moneyunit; const radioType = store.datatype.find((v) => v.code === currentField.format); -var selectUnit = currentField.format === "number" ? moneyunit.find((v) => v.detail === currentField.unit) : undefined; -var bgcolor = undefined; -var radioBGcolor = colorchoice.find((v) => v.code === "none"); -var color = undefined; -var radioColor = colorchoice.find((v) => v.code === "none"); -var textsize = undefined; -var radioSize = colorchoice.find((v) => v.code === "none"); +// var selectUnit = currentField.format === "number" ? moneyunit.find((v) => v.detail === currentField.unit) : undefined; +// var bgcolor = undefined; +// var radioBGcolor = colorchoice.find((v) => v.code === "none"); +// var color = undefined; +// var radioColor = colorchoice.find((v) => v.code === "none"); +// var textsize = undefined; +// var radioSize = colorchoice.find((v) => v.code === "none"); var minwidth = undefined; -var radioWidth = colorchoice.find((v) => v.code === "none"); -var radioMaxWidth = colorchoice.find((v) => v.code === "none"); +// var radioWidth = colorchoice.find((v) => v.code === "none"); +// var radioMaxWidth = colorchoice.find((v) => v.code === "none"); var maxwidth = undefined; -var selectAlign = undefined; -var radioAlign = colorchoice.find((v) => v.code === "none"); +// var selectAlign = undefined; +// var radioAlign = colorchoice.find((v) => v.code === "none"); var radioTemplate = ref(colorchoice.find((v) => v.code === (currentField.template ? "option" : "none"))["code"]); -var selectPlacement = store.placement.find((v) => v.code === "is-right"); -var selectScheme = store.colorscheme.find((v) => v.code === "is-primary"); -var radioTooltip = store.colorchoice.find((v) => v.code === "none"); -var selectField = undefined; -var tags = currentField.tags ? currentField.tags.map((v) => fields.find((x) => x.name === v)) : []; -var formula = currentField.formula ? currentField.formula : undefined; +// var selectPlacement = store.placement.find((v) => v.code === "is-right"); +// var selectScheme = store.colorscheme.find((v) => v.code === "is-primary"); +// var radioTooltip = store.colorchoice.find((v) => v.code === "none"); +// var selectField = undefined; +// var tags = currentField.tags ? currentField.tags.map((v) => fields.find((x) => x.name === v)) : []; +// var formula = currentField.formula ? currentField.formula : undefined; var decimal = currentField.decimal; let shortmenu = store.menuchoice.filter((x) => currentField.format === "number" diff --git a/app/components/datatable/CreateTemplate.vue b/app/components/datatable/CreateTemplate.vue index 764ed39..fce37c1 100644 --- a/app/components/datatable/CreateTemplate.vue +++ b/app/components/datatable/CreateTemplate.vue @@ -615,7 +615,7 @@ const checkExpression = function () { tagsField.forEach((v) => { let myRegExp = new RegExp(v.name, "g"); val = val.replace(myRegExp, Math.random()); - exp = exp.replace(myRegExp, "formatNumber(row['" + v.name + "'])"); + exp = exp.replace(myRegExp, "parseNum(row['" + v.name + "'])"); }); try { let value = $calc(val); diff --git a/app/components/datatable/DataTable.vue b/app/components/datatable/DataTable.vue index b5b138b..61bf706 100644 --- a/app/components/datatable/DataTable.vue +++ b/app/components/datatable/DataTable.vue @@ -147,7 +147,7 @@ const { $empty, $find, $getEditRights, - $formatNumber, + $parseNum, $multiSort, $remove, $stripHtml, @@ -420,8 +420,8 @@ const frontendFilter = function (newVal) { else { let text = ""; filter.map((y, k) => { - text += `${k > 0 ? (filter[k - 1].operator === "and" ? " &&" : " ||") : ""} ${$formatNumber(x[name])} - ${y.condition === "=" ? "==" : y.condition === "<>" ? "!==" : y.condition} ${$formatNumber(y.value)}`; + text += `${k > 0 ? (filter[k - 1].operator === "and" ? " &&" : " ||") : ""} ${$parseNum(x[name])} + ${y.condition === "=" ? "==" : y.condition === "<>" ? "!==" : y.condition} ${$parseNum(y.value)}`; }); return $calc(text); } @@ -541,7 +541,7 @@ const updateData = async function (newVal) { } if (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; } tablesetting = $copy(pagedata.tablesetting || gridsetting); diff --git a/app/components/datatable/FilterOption.vue b/app/components/datatable/FilterOption.vue index 8f4f79d..88baced 100644 --- a/app/components/datatable/FilterOption.vue +++ b/app/components/datatable/FilterOption.vue @@ -238,7 +238,7 @@ export default { this.tagsField.forEach((v) => { let myRegExp = new RegExp(v.name, "g"); 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 { let value = this.$calc(val); diff --git a/app/components/datatable/PivotDataView.vue b/app/components/datatable/PivotDataView.vue index 05b81e5..f3051aa 100644 --- a/app/components/datatable/PivotDataView.vue +++ b/app/components/datatable/PivotDataView.vue @@ -221,8 +221,8 @@ const { $stripHtml, $snackbar, $dayjs, - $formatNumber, - $numtoString, + $parseNum, + $formatNum, $empty, $unique, $multiSort, @@ -523,9 +523,9 @@ const formatCellValue = (value, field) => { if (value === undefined || value === null || value === "") return "-"; if (field.format === "number") { - const num = $formatNumber(value); + const num = $parseNum(value); 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") { @@ -596,8 +596,8 @@ const getDataCellStyle = (row, leaf) => { if (cell && leaf.field) { if (leaf.field === "paid_amount") { - const amount = $formatNumber(cell.amount) || 0; - const paid = $formatNumber(cell.paid_amount) || 0; + const amount = $parseNum(cell.amount) || 0; + const paid = $parseNum(cell.paid_amount) || 0; if (paid >= amount) { style += " background-color: #d4edda;"; } else if (paid > 0) { @@ -608,8 +608,8 @@ const getDataCellStyle = (row, leaf) => { } if (leaf.field === "to_date") { const dueDate = cell.to_date; - const paid = $formatNumber(cell.paid_amount) || 0; - const amount = $formatNumber(cell.amount) || 0; + const paid = $parseNum(cell.paid_amount) || 0; + const amount = $parseNum(cell.amount) || 0; if (dueDate && paid < amount) { const today = new Date(); const due = new Date(dueDate); diff --git a/app/components/datatable/TimeOption.vue b/app/components/datatable/TimeOption.vue index 60f4929..d8e1a70 100644 --- a/app/components/datatable/TimeOption.vue +++ b/app/components/datatable/TimeOption.vue @@ -433,7 +433,7 @@ export default { checkTimeopt() { if (this.timeopt > 0) { let obj = this.$find(this.options, { - code: this.$formatNumber(this.timeopt), + code: this.$parseNum(this.timeopt), }); 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.time) { let obj = this.$find(this.options, { - code: this.$formatNumber(this.timeopt.time), + code: this.$parseNum(this.timeopt.time), }); if (obj) this.current = obj.code; } diff --git a/app/components/inventory/SelectedInvItem.vue b/app/components/inventory/SelectedInvItem.vue index 38962d9..773f754 100644 --- a/app/components/inventory/SelectedInvItem.vue +++ b/app/components/inventory/SelectedInvItem.vue @@ -3,7 +3,7 @@ const props = defineProps({ invItem: Object, }); -const { $dayjs, $numtoString } = useNuxtApp(); +const { $dayjs, $formatNum } = useNuxtApp(); const emit = defineEmits("unselect"); @@ -54,13 +54,13 @@ const emit = defineEmits("unselect");

Giá đơn vị

- {{ $numtoString(invItem.unit_price, { hasUnit: true }) }} + {{ $formatNum(invItem.unit_price, { hasUnit: true }) }}

Tổng giá trị

- {{ $numtoString(invItem.total, { hasUnit: true }) }} + {{ $formatNum(invItem.total, { hasUnit: true }) }}

diff --git a/app/components/orders/OrderPaymentTab.vue b/app/components/orders/OrderPaymentTab.vue index c3b0b7d..0e7d33d 100644 --- a/app/components/orders/OrderPaymentTab.vue +++ b/app/components/orders/OrderPaymentTab.vue @@ -2,7 +2,7 @@ const props = defineProps({ invoice: Object, }); -const { $numtoString } = useNuxtApp(); +const { $formatNum } = useNuxtApp();