chore: install prettier
This commit is contained in:
@@ -1,277 +1,271 @@
|
||||
|
||||
import { useStore } from '~/stores/index'
|
||||
import { useStore } from "~/stores/index";
|
||||
export default defineNuxtPlugin(() => {
|
||||
const store = useStore()
|
||||
const store = useStore();
|
||||
|
||||
//==========Find & filter=================
|
||||
const find = function(arr, obj, attr) {
|
||||
const keys = Object.keys(obj)
|
||||
let found = arr.find(v=>{
|
||||
let valid = true
|
||||
keys.map(key=>{
|
||||
let val = obj[key]
|
||||
if(valid===false) return false
|
||||
else if(Array.isArray(val)) {
|
||||
if(val.findIndex(x=>x===v[key]) <0) valid = false
|
||||
} else if(!(v[key]===val)) valid = false
|
||||
})
|
||||
return valid
|
||||
})
|
||||
return found? (attr? found[attr] : found) : undefined
|
||||
}
|
||||
const find = function (arr, obj, attr) {
|
||||
const keys = Object.keys(obj);
|
||||
let found = arr.find((v) => {
|
||||
let valid = true;
|
||||
keys.map((key) => {
|
||||
let val = obj[key];
|
||||
if (valid === false) return false;
|
||||
else if (Array.isArray(val)) {
|
||||
if (val.findIndex((x) => x === v[key]) < 0) valid = false;
|
||||
} else if (!(v[key] === val)) valid = false;
|
||||
});
|
||||
return valid;
|
||||
});
|
||||
return found ? (attr ? found[attr] : found) : undefined;
|
||||
};
|
||||
|
||||
const findIndex = function(arr, obj) {
|
||||
const keys = Object.keys(obj)
|
||||
return arr.findIndex(v=>{
|
||||
let valid = true
|
||||
keys.map(key=>{
|
||||
let val = obj[key]
|
||||
if(valid===false) return false
|
||||
else if(Array.isArray(val)) {
|
||||
if(val.findIndex(x=>x===v[key]) <0) valid = false
|
||||
} else if(!(v[key]===val)) valid = false
|
||||
})
|
||||
return valid
|
||||
})
|
||||
}
|
||||
const findIndex = function (arr, obj) {
|
||||
const keys = Object.keys(obj);
|
||||
return arr.findIndex((v) => {
|
||||
let valid = true;
|
||||
keys.map((key) => {
|
||||
let val = obj[key];
|
||||
if (valid === false) return false;
|
||||
else if (Array.isArray(val)) {
|
||||
if (val.findIndex((x) => x === v[key]) < 0) valid = false;
|
||||
} else if (!(v[key] === val)) valid = false;
|
||||
});
|
||||
return valid;
|
||||
});
|
||||
};
|
||||
|
||||
const filter = function(arr, obj, attr) {
|
||||
const keys = Object.keys(obj)
|
||||
let rows = arr.filter(v=>{
|
||||
let valid = true
|
||||
keys.map(key=>{
|
||||
let val = obj[key]
|
||||
if(valid===false) return false
|
||||
else if(Array.isArray(val)) {
|
||||
if(val.findIndex(x=>x===v[key]) <0) valid = false
|
||||
} else if(!(v[key]===val)) valid = false
|
||||
})
|
||||
return valid
|
||||
})
|
||||
return attr? rows.map(v=>v[attr]) : rows
|
||||
}
|
||||
const filter = function (arr, obj, attr) {
|
||||
const keys = Object.keys(obj);
|
||||
let rows = arr.filter((v) => {
|
||||
let valid = true;
|
||||
keys.map((key) => {
|
||||
let val = obj[key];
|
||||
if (valid === false) return false;
|
||||
else if (Array.isArray(val)) {
|
||||
if (val.findIndex((x) => x === v[key]) < 0) valid = false;
|
||||
} else if (!(v[key] === val)) valid = false;
|
||||
});
|
||||
return valid;
|
||||
});
|
||||
return attr ? rows.map((v) => v[attr]) : rows;
|
||||
};
|
||||
|
||||
//=========Empty & copy============
|
||||
const id = function() {
|
||||
return Math.random().toString(36).substring(2, 12).toUpperCase()
|
||||
}
|
||||
const id = function () {
|
||||
return Math.random().toString(36).substring(2, 12).toUpperCase();
|
||||
};
|
||||
|
||||
const empty = function(val) {
|
||||
return val === undefined || val === null || val === ''
|
||||
}
|
||||
const empty = function (val) {
|
||||
return val === undefined || val === null || val === "";
|
||||
};
|
||||
|
||||
const copy = function(val) {
|
||||
if (empty(val)) return val
|
||||
return JSON.parse(JSON.stringify(val))
|
||||
}
|
||||
const copy = function (val) {
|
||||
if (empty(val)) return val;
|
||||
return JSON.parse(JSON.stringify(val));
|
||||
};
|
||||
|
||||
const clone = function(obj) {
|
||||
if (obj === null || typeof (obj) !== 'object' || 'isActiveClone' in obj)
|
||||
return obj;
|
||||
const clone = function (obj) {
|
||||
if (obj === null || typeof obj !== "object" || "isActiveClone" in obj) return obj;
|
||||
if (obj instanceof Date)
|
||||
var temp = new obj.constructor(); //or new Date(obj);
|
||||
else
|
||||
var temp = obj.constructor();
|
||||
else var temp = obj.constructor();
|
||||
for (var key in obj) {
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
obj['isActiveClone'] = null;
|
||||
obj["isActiveClone"] = null;
|
||||
temp[key] = clone(obj[key]);
|
||||
delete obj['isActiveClone'];
|
||||
delete obj["isActiveClone"];
|
||||
}
|
||||
}
|
||||
return temp
|
||||
}
|
||||
return temp;
|
||||
};
|
||||
|
||||
const remove = function(arr, idx) {
|
||||
arr.splice(idx, 1)
|
||||
}
|
||||
const remove = function (arr, idx) {
|
||||
arr.splice(idx, 1);
|
||||
};
|
||||
|
||||
const stripHtml = function(html, length) {
|
||||
if(!html) return null
|
||||
else if(typeof html!=='string') return html
|
||||
if(html? html.indexOf('<')<0 : false) {
|
||||
return length? (html.length > length? html.substring(0, length) + '...' : html ) : html
|
||||
const stripHtml = function (html, length) {
|
||||
if (!html) return null;
|
||||
else if (typeof html !== "string") return html;
|
||||
if (html ? html.indexOf("<") < 0 : false) {
|
||||
return length ? (html.length > length ? html.substring(0, length) + "..." : html) : html;
|
||||
}
|
||||
var tmp = document.createElement("DIV")
|
||||
tmp.innerHTML = html
|
||||
var val = tmp.textContent || tmp.innerText || ""
|
||||
return length? (val.length > length? val.substring(0, length) + '...' : val ) : val
|
||||
}
|
||||
var tmp = document.createElement("DIV");
|
||||
tmp.innerHTML = html;
|
||||
var val = tmp.textContent || tmp.innerText || "";
|
||||
return length ? (val.length > length ? val.substring(0, length) + "..." : val) : val;
|
||||
};
|
||||
|
||||
//==========Convert=================
|
||||
const isNumber = function(val) {
|
||||
if(empty(val)) return false
|
||||
val = val.toString().replace(/,/g, "")
|
||||
return !isNaN(val)
|
||||
}
|
||||
const isNumber = function (val) {
|
||||
if (empty(val)) return false;
|
||||
val = val.toString().replace(/,/g, "");
|
||||
return !isNaN(val);
|
||||
};
|
||||
|
||||
const numtoString = function(val, config = undefined) {
|
||||
if (empty(val)) return '0';
|
||||
const numtoString = function (val, config = undefined) {
|
||||
if (empty(val)) return "0";
|
||||
val = val.toString().replace(/,/g, "");
|
||||
if (isNaN(val)) return;
|
||||
|
||||
const defaultConfig = {
|
||||
type: 'vi-VN',
|
||||
const defaultConfig = {
|
||||
type: "vi-VN",
|
||||
decimal: undefined,
|
||||
mindecimal: undefined,
|
||||
hasUnit: false
|
||||
hasUnit: false,
|
||||
};
|
||||
|
||||
const finalConfig = { ...defaultConfig, ...config };
|
||||
const { type, decimal, mindecimal, hasUnit } = finalConfig;
|
||||
|
||||
const options = {};
|
||||
if (typeof decimal === 'number') options.maximumFractionDigits = decimal || 0;
|
||||
if (typeof decimal === "number") options.maximumFractionDigits = decimal || 0;
|
||||
if (mindecimal) options.minimumFractionDigits = mindecimal;
|
||||
const unit = hasUnit ? ' đ' : '';
|
||||
return Number(val).toLocaleString(type, typeof decimal === 'number' ? options : undefined) + unit;
|
||||
}
|
||||
const unit = hasUnit ? " đ" : "";
|
||||
return Number(val).toLocaleString(type, typeof decimal === "number" ? options : undefined) + unit;
|
||||
};
|
||||
|
||||
const formatNumber = function(val) {
|
||||
if(empty(val)) return
|
||||
val = val.toString().replace(/[,\.]/g, "")
|
||||
if (val.indexOf('%') >0) {
|
||||
val = val.replace(/%/g, "")
|
||||
return isNaN(val)? undefined : Number(val)/100
|
||||
const formatNumber = function (val) {
|
||||
if (empty(val)) return;
|
||||
val = val.toString().replace(/[,\.]/g, "");
|
||||
if (val.indexOf("%") > 0) {
|
||||
val = val.replace(/%/g, "");
|
||||
return isNaN(val) ? undefined : Number(val) / 100;
|
||||
}
|
||||
return isNaN(val)? undefined : Number(val)
|
||||
}
|
||||
return isNaN(val) ? undefined : Number(val);
|
||||
};
|
||||
|
||||
const formatUnit = function(val, unit, decimal, string, mindecimal) {
|
||||
val = formatNumber(val)
|
||||
if(val===undefined) return
|
||||
let percentage = (unit===0.01 || unit==="0.01")? '%' : ''
|
||||
val = unit? val/Number(unit) : val
|
||||
let f = {maximumFractionDigits: decimal || 0}
|
||||
if(mindecimal) f['minimumFractionDigits'] = mindecimal
|
||||
return string? (val.toLocaleString('en-EN', f) + percentage) : (val).toFixed(decimal)
|
||||
}
|
||||
const formatUnit = function (val, unit, decimal, string, mindecimal) {
|
||||
val = formatNumber(val);
|
||||
if (val === undefined) return;
|
||||
let percentage = unit === 0.01 || unit === "0.01" ? "%" : "";
|
||||
val = unit ? val / Number(unit) : val;
|
||||
let f = { maximumFractionDigits: decimal || 0 };
|
||||
if (mindecimal) f["minimumFractionDigits"] = mindecimal;
|
||||
return string ? val.toLocaleString("en-EN", f) + percentage : val.toFixed(decimal);
|
||||
};
|
||||
|
||||
//==========Calculate=================
|
||||
const calc = function(fn) {
|
||||
return new Function('return ' + fn)()
|
||||
}
|
||||
//==========Calculate=================
|
||||
const calc = function (fn) {
|
||||
return new Function("return " + fn)();
|
||||
};
|
||||
|
||||
const calculate = function(row, tags, formula, decimal, unit) {
|
||||
let val = this.$copy(formula)
|
||||
let valid = 0
|
||||
tags.forEach(v => {
|
||||
let myRegExp = new RegExp(v, 'g')
|
||||
let res = this.$formatNumber(row[v])
|
||||
if(res) valid = 1
|
||||
val = val.replace(myRegExp, `(${res || 0})`)
|
||||
})
|
||||
if(valid===0) return {success: false, value : undefined} //all values is null
|
||||
const calculate = function (row, tags, formula, decimal, unit) {
|
||||
let val = this.$copy(formula);
|
||||
let valid = 0;
|
||||
tags.forEach((v) => {
|
||||
let myRegExp = new RegExp(v, "g");
|
||||
let res = this.$formatNumber(row[v]);
|
||||
if (res) valid = 1;
|
||||
val = val.replace(myRegExp, `(${res || 0})`);
|
||||
});
|
||||
if (valid === 0) return { success: false, value: undefined }; //all values is null
|
||||
//calculate
|
||||
try {
|
||||
let value = this.$calc(val)
|
||||
if(isNaN(value) || value===Number.POSITIVE_INFINITY || value===Number.NEGATIVE_INFINITY) {
|
||||
var result = {success: false, value : value}
|
||||
let value = this.$calc(val);
|
||||
if (isNaN(value) || value === Number.POSITIVE_INFINITY || value === Number.NEGATIVE_INFINITY) {
|
||||
var result = { success: false, value: value };
|
||||
} else {
|
||||
value = (value===true || value===false)? value : formatUnit(value, unit, decimal, true, decimal)
|
||||
var result = {success: true, value: value}
|
||||
value = value === true || value === false ? value : formatUnit(value, unit, decimal, true, decimal);
|
||||
var result = { success: true, value: value };
|
||||
}
|
||||
} catch (err) {
|
||||
var result = { success: false, value: undefined };
|
||||
}
|
||||
catch(err) {
|
||||
var result = {success: false, value : undefined}
|
||||
}
|
||||
return result
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
const calculateFunc = function(row, cols, func, decimal, unit) {
|
||||
let value
|
||||
let arr1 = cols.map(v=>this.$formatNumber(row[v]))
|
||||
let arr = arr1.filter(v=>v)
|
||||
if(arr.length===0) return {success: false, value : undefined}
|
||||
if(func==='max') value = Math.max(...arr)
|
||||
else if(func==='min') value = Math.min(...arr)
|
||||
else if(func==='sum') value = arr.reduce((a, b) => a + b, 0)
|
||||
else if(func==='avg') {
|
||||
let total = arr.reduce((a, b) => a + b, 0)
|
||||
value = total / cols.length
|
||||
const calculateFunc = function (row, cols, func, decimal, unit) {
|
||||
let value;
|
||||
let arr1 = cols.map((v) => this.$formatNumber(row[v]));
|
||||
let arr = arr1.filter((v) => v);
|
||||
if (arr.length === 0) return { success: false, value: undefined };
|
||||
if (func === "max") value = Math.max(...arr);
|
||||
else if (func === "min") value = Math.min(...arr);
|
||||
else if (func === "sum") value = arr.reduce((a, b) => a + b, 0);
|
||||
else if (func === "avg") {
|
||||
let total = arr.reduce((a, b) => a + b, 0);
|
||||
value = total / cols.length;
|
||||
}
|
||||
if(!value) return {success: false, value: undefined}
|
||||
value = formatUnit(value, unit, decimal, true, decimal)
|
||||
return {success: true, value: value}
|
||||
}
|
||||
if (!value) return { success: false, value: undefined };
|
||||
value = formatUnit(value, unit, decimal, true, decimal);
|
||||
return { success: true, value: value };
|
||||
};
|
||||
|
||||
const calculateData = function(data, fields) {
|
||||
let arr = this.$copy(fields.filter(h=>h.formula))
|
||||
if(arr.length===0) return data
|
||||
let arr1 = arr.filter(v=>v.func)
|
||||
arr1.map(v=>{
|
||||
if(v.vals.indexOf(':')>=0) {
|
||||
let arr2 = v.vals.toLowerCase().replaceAll('c', '').split(':')
|
||||
let cols = []
|
||||
const calculateData = function (data, fields) {
|
||||
let arr = this.$copy(fields.filter((h) => h.formula));
|
||||
if (arr.length === 0) return data;
|
||||
let arr1 = arr.filter((v) => v.func);
|
||||
arr1.map((v) => {
|
||||
if (v.vals.indexOf(":") >= 0) {
|
||||
let arr2 = v.vals.toLowerCase().replaceAll("c", "").split(":");
|
||||
let cols = [];
|
||||
for (let i = parseInt(arr2[0]); i <= parseInt(arr2[1]); i++) {
|
||||
let field = fields.length>i? fields[i] : undefined
|
||||
if(field? (field.format==='number' && field.name!==v.name) : false) cols.push(field.name)
|
||||
let field = fields.length > i ? fields[i] : undefined;
|
||||
if (field ? field.format === "number" && field.name !== v.name : false) cols.push(field.name);
|
||||
}
|
||||
v.cols = cols
|
||||
v.cols = cols;
|
||||
} else {
|
||||
let arr2 = v.vals.toLowerCase().replaceAll('c', '').split(',')
|
||||
let cols = []
|
||||
arr2.map(v=>{
|
||||
let i = parseInt(v)
|
||||
let field = fields.length>i? fields[i] : undefined
|
||||
if(field? (field.format==='number' && field.name!==v.name) : false) cols.push(field.name)
|
||||
})
|
||||
v.cols = cols
|
||||
let arr2 = v.vals.toLowerCase().replaceAll("c", "").split(",");
|
||||
let cols = [];
|
||||
arr2.map((v) => {
|
||||
let i = parseInt(v);
|
||||
let field = fields.length > i ? fields[i] : undefined;
|
||||
if (field ? field.format === "number" && field.name !== v.name : false) cols.push(field.name);
|
||||
});
|
||||
v.cols = cols;
|
||||
}
|
||||
})
|
||||
arr = multiSort(arr, {level: 'asc'})
|
||||
let copy = data
|
||||
copy.map(v=>{
|
||||
arr.map(x=>{
|
||||
if(x.func) {
|
||||
let res = calculateFunc(v, x.cols, x.func, x.decimal, x.unit)
|
||||
if(res? res.success : false) v[x.name] = res.value
|
||||
});
|
||||
arr = multiSort(arr, { level: "asc" });
|
||||
let copy = data;
|
||||
copy.map((v) => {
|
||||
arr.map((x) => {
|
||||
if (x.func) {
|
||||
let res = calculateFunc(v, x.cols, x.func, x.decimal, x.unit);
|
||||
if (res ? res.success : false) v[x.name] = res.value;
|
||||
} else {
|
||||
let res = calculate(v, x.tags, x.formula, x.decimal, x.unit)
|
||||
if(res? res.success : false) v[x.name] = res.value
|
||||
let res = calculate(v, x.tags, x.formula, x.decimal, x.unit);
|
||||
if (res ? res.success : false) v[x.name] = res.value;
|
||||
}
|
||||
})
|
||||
})
|
||||
return copy
|
||||
}
|
||||
});
|
||||
});
|
||||
return copy;
|
||||
};
|
||||
|
||||
const summary = function(arr, fields, type) {
|
||||
let obj = {}
|
||||
if(type==='total') {
|
||||
fields.map(x=> obj[x] = arr.map(v=>v[x]? v[x] : 0).reduce((a, b) => a + b, 0))
|
||||
} else if(type==='min') {
|
||||
fields.map(x=>obj[x] = Math.min(...arr.map(v=>v[x])))
|
||||
const summary = function (arr, fields, type) {
|
||||
let obj = {};
|
||||
if (type === "total") {
|
||||
fields.map((x) => (obj[x] = arr.map((v) => (v[x] ? v[x] : 0)).reduce((a, b) => a + b, 0)));
|
||||
} else if (type === "min") {
|
||||
fields.map((x) => (obj[x] = Math.min(...arr.map((v) => v[x]))));
|
||||
} else if (type === "max") {
|
||||
fields.map((x) => (obj[x] = Math.max(...arr.map((v) => v[x]))));
|
||||
} else if (type === "count") {
|
||||
fields.map((x) => (obj[x] = arr.map((v) => !empty(v[x])).length));
|
||||
}
|
||||
else if(type==='max') {
|
||||
fields.map(x=>obj[x] = Math.max(...arr.map(v=>v[x])))
|
||||
}
|
||||
else if(type==='count') {
|
||||
fields.map(x=>obj[x] = arr.map(v=>!empty(v[x])).length)
|
||||
}
|
||||
return obj
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
|
||||
//====================Array====================
|
||||
const formatArray = function(data, fields) {
|
||||
let args = fields.filter(v=>v.format==='number')
|
||||
data.map(v=>{
|
||||
args.map(x=>{
|
||||
v[x.name] = empty(v[x.name])? undefined : formatUnit(v[x.name], x.unit, x.decimal, true, x.decimal)
|
||||
})
|
||||
})
|
||||
return data
|
||||
}
|
||||
//====================Array====================
|
||||
const formatArray = function (data, fields) {
|
||||
let args = fields.filter((v) => v.format === "number");
|
||||
data.map((v) => {
|
||||
args.map((x) => {
|
||||
v[x.name] = empty(v[x.name]) ? undefined : formatUnit(v[x.name], x.unit, x.decimal, true, x.decimal);
|
||||
});
|
||||
});
|
||||
return data;
|
||||
};
|
||||
|
||||
const unique = function(arr, keyProps) {
|
||||
const kvArray = arr.map(entry => {
|
||||
const key = keyProps.map(k => entry[k]).join('|');
|
||||
return [key, entry];
|
||||
const unique = function (arr, keyProps) {
|
||||
const kvArray = arr.map((entry) => {
|
||||
const key = keyProps.map((k) => entry[k]).join("|");
|
||||
return [key, entry];
|
||||
});
|
||||
const map = new Map(kvArray);
|
||||
return Array.from(map.values());
|
||||
}
|
||||
|
||||
const arrayMove = function(arr, old_index, new_index) {
|
||||
};
|
||||
|
||||
const arrayMove = function (arr, old_index, new_index) {
|
||||
if (new_index >= arr.length) {
|
||||
var k = new_index - arr.length + 1;
|
||||
while (k--) {
|
||||
@@ -280,124 +274,150 @@ export default defineNuxtPlugin(() => {
|
||||
}
|
||||
arr.splice(new_index, 0, arr.splice(old_index, 1)[0]);
|
||||
return arr; // for testing
|
||||
}
|
||||
};
|
||||
|
||||
const multiSort = function(array, sortObject = {}, format = {}) {
|
||||
const sortKeys = Object.keys(sortObject)
|
||||
const multiSort = function (array, sortObject = {}, format = {}) {
|
||||
const sortKeys = Object.keys(sortObject);
|
||||
|
||||
// Return array if no sort object is supplied.
|
||||
if (!sortKeys.length) return array
|
||||
if (!sortKeys.length) return array;
|
||||
|
||||
// Change the values of the sortObject keys to -1, 0, or 1.
|
||||
for (let key in sortObject)
|
||||
sortObject[key] = sortObject[key] === 'desc' || sortObject[key] === -1 ? -1 : (sortObject[key] === 'skip' || sortObject[key] === 0 ? 0 : 1)
|
||||
sortObject[key] =
|
||||
sortObject[key] === "desc" || sortObject[key] === -1
|
||||
? -1
|
||||
: sortObject[key] === "skip" || sortObject[key] === 0
|
||||
? 0
|
||||
: 1;
|
||||
|
||||
const keySort = (a, b, direction) => {
|
||||
direction = direction !== null ? direction : 1
|
||||
if (a === b) return 0
|
||||
direction = direction !== null ? direction : 1;
|
||||
if (a === b) return 0;
|
||||
|
||||
// If b > a, multiply by -1 to get the reverse direction.
|
||||
return a > b ? direction : -1 * direction;
|
||||
}
|
||||
// If b > a, multiply by -1 to get the reverse direction.
|
||||
return a > b ? direction : -1 * direction;
|
||||
};
|
||||
|
||||
return array.sort((a, b) => {
|
||||
let sorted = 0, index = 0
|
||||
let sorted = 0,
|
||||
index = 0;
|
||||
|
||||
// Loop until sorted (-1 or 1) or until the sort keys have been processed.
|
||||
while (sorted === 0 && index < sortKeys.length) {
|
||||
const key = sortKeys[index]
|
||||
const key = sortKeys[index];
|
||||
if (key) {
|
||||
const direction = sortObject[key]
|
||||
let val1 = format[key]==='number'? (empty(a[key])? 0 : this.$formatNumber(a[key])) : a[key]
|
||||
let val2 = format[key]==='number'? (empty(b[key])? 0 : this.$formatNumber(b[key])) : b[key]
|
||||
sorted = keySort(val1, val2, direction)
|
||||
index++
|
||||
}
|
||||
const direction = sortObject[key];
|
||||
let val1 = format[key] === "number" ? (empty(a[key]) ? 0 : this.$formatNumber(a[key])) : a[key];
|
||||
let val2 = format[key] === "number" ? (empty(b[key]) ? 0 : this.$formatNumber(b[key])) : b[key];
|
||||
sorted = keySort(val1, val2, direction);
|
||||
index++;
|
||||
}
|
||||
return sorted
|
||||
})
|
||||
}
|
||||
}
|
||||
return sorted;
|
||||
});
|
||||
};
|
||||
|
||||
//======================Fields====================
|
||||
const createField = function(name,label,format,show, minwidth) {
|
||||
let field = {name: name, label: label, format: format, show: show, minwidth: minwidth}
|
||||
if(format==='number') {
|
||||
field.unit = '1'
|
||||
field.textalign = 'right'
|
||||
const createField = function (name, label, format, show, minwidth) {
|
||||
let field = {
|
||||
name: name,
|
||||
label: label,
|
||||
format: format,
|
||||
show: show,
|
||||
minwidth: minwidth,
|
||||
};
|
||||
if (format === "number") {
|
||||
field.unit = "1";
|
||||
field.textalign = "right";
|
||||
}
|
||||
return field
|
||||
}
|
||||
return field;
|
||||
};
|
||||
|
||||
const updateFields = function(pagename, field, action) {
|
||||
let pagedata = store[pagename]
|
||||
let copy = this.$copy(pagedata.fields)
|
||||
let idx = this.$findIndex(copy, {name: field.name})
|
||||
if(action==='delete') {
|
||||
this.$delete(copy, idx)
|
||||
if(pagedata.filters? pagedata.filters.length>0 : false) {
|
||||
let index = this.$findIndex(pagedata.filters, {name: field.name})
|
||||
if(index>=0) {
|
||||
let copyFilter = this.$copy(this.pagedata.filters)
|
||||
this.$delete(copyFilter, index)
|
||||
this.$store.commit('updateState', {name: pagename, key: 'filterby', data: copyFilter})
|
||||
const updateFields = function (pagename, field, action) {
|
||||
let pagedata = store[pagename];
|
||||
let copy = this.$copy(pagedata.fields);
|
||||
let idx = this.$findIndex(copy, { name: field.name });
|
||||
if (action === "delete") {
|
||||
this.$delete(copy, idx);
|
||||
if (pagedata.filters ? pagedata.filters.length > 0 : false) {
|
||||
let index = this.$findIndex(pagedata.filters, { name: field.name });
|
||||
if (index >= 0) {
|
||||
let copyFilter = this.$copy(this.pagedata.filters);
|
||||
this.$delete(copyFilter, index);
|
||||
this.$store.commit("updateState", {
|
||||
name: pagename,
|
||||
key: "filterby",
|
||||
data: copyFilter,
|
||||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
idx>=0? copy[idx] = field : copy.push(field)
|
||||
idx >= 0 ? (copy[idx] = field) : copy.push(field);
|
||||
}
|
||||
this.$store.commit("updateState", {name: pagename, key: "fields", data: copy})
|
||||
}
|
||||
this.$store.commit("updateState", {
|
||||
name: pagename,
|
||||
key: "fields",
|
||||
data: copy,
|
||||
});
|
||||
};
|
||||
|
||||
const updateSeriesFields = function(fields) {
|
||||
const updateSeriesFields = function (fields) {
|
||||
if (!Array.isArray(fields)) {
|
||||
fields = Object.values(fields);
|
||||
}
|
||||
|
||||
fields.filter(v=>v.series).map(field=>{
|
||||
let obj = field.api==='finitem'? this.$findPeriod(field.series, 'period') : this.$findPeriod(field.series)
|
||||
field.period = field.api==='finitem'? obj.code : obj
|
||||
let idx = field.label.indexOf('[')
|
||||
field.label = (idx>0? field.label.substring(0, idx) : field.label) + '[' + (field.api==='finitem'? obj.show : obj) + ']'
|
||||
})
|
||||
return fields
|
||||
}
|
||||
|
||||
const updateSeriesFilters = function(filters, fields) {
|
||||
if(fields.filter(v=>v.series).length===0) return filters
|
||||
filters.map(v=>{
|
||||
let found = fields.find(x=>x.name===v.name)
|
||||
if(found? found.series : false) {
|
||||
v.label = found.label
|
||||
}
|
||||
})
|
||||
return filters
|
||||
}
|
||||
|
||||
//======================Export===============================
|
||||
const exportExcel = function(data, filename, fields) {
|
||||
var _filename = filename + '.xlsx'
|
||||
let list = []
|
||||
data.map(v=>{
|
||||
let ele = {}
|
||||
fields.map(x=>{
|
||||
let label = stripHtml(x.label)
|
||||
ele[label] = v[x.name]
|
||||
})
|
||||
list.push(ele)
|
||||
})
|
||||
var XLSX = require('xlsx')
|
||||
fields
|
||||
.filter((v) => v.series)
|
||||
.map((field) => {
|
||||
let obj = field.api === "finitem" ? this.$findPeriod(field.series, "period") : this.$findPeriod(field.series);
|
||||
field.period = field.api === "finitem" ? obj.code : obj;
|
||||
let idx = field.label.indexOf("[");
|
||||
field.label =
|
||||
(idx > 0 ? field.label.substring(0, idx) : field.label) +
|
||||
"[" +
|
||||
(field.api === "finitem" ? obj.show : obj) +
|
||||
"]";
|
||||
});
|
||||
return fields;
|
||||
};
|
||||
|
||||
const updateSeriesFilters = function (filters, fields) {
|
||||
if (fields.filter((v) => v.series).length === 0) return filters;
|
||||
filters.map((v) => {
|
||||
let found = fields.find((x) => x.name === v.name);
|
||||
if (found ? found.series : false) {
|
||||
v.label = found.label;
|
||||
}
|
||||
});
|
||||
return filters;
|
||||
};
|
||||
|
||||
//======================Export===============================
|
||||
const exportExcel = function (data, filename, fields) {
|
||||
var _filename = filename + ".xlsx";
|
||||
let list = [];
|
||||
data.map((v) => {
|
||||
let ele = {};
|
||||
fields.map((x) => {
|
||||
let label = stripHtml(x.label);
|
||||
ele[label] = v[x.name];
|
||||
});
|
||||
list.push(ele);
|
||||
});
|
||||
var XLSX = require("xlsx");
|
||||
//workBook class
|
||||
function Workbook() {
|
||||
if(!(this instanceof Workbook)) return new Workbook()
|
||||
this.SheetNames = []
|
||||
this.Sheets = {}
|
||||
if (!(this instanceof Workbook)) return new Workbook();
|
||||
this.SheetNames = [];
|
||||
this.Sheets = {};
|
||||
}
|
||||
var exportBook = new Workbook();
|
||||
var worksheet = XLSX.utils.json_to_sheet(list)
|
||||
exportBook.SheetNames.push('sheet1')
|
||||
exportBook.Sheets.sheet1 = worksheet
|
||||
XLSX.writeFile(exportBook, _filename)
|
||||
}
|
||||
var worksheet = XLSX.utils.json_to_sheet(list);
|
||||
exportBook.SheetNames.push("sheet1");
|
||||
exportBook.Sheets.sheet1 = worksheet;
|
||||
XLSX.writeFile(exportBook, _filename);
|
||||
};
|
||||
|
||||
return {
|
||||
provide: {
|
||||
@@ -427,7 +447,7 @@ export default defineNuxtPlugin(() => {
|
||||
updateFields,
|
||||
updateSeriesFields,
|
||||
updateSeriesFilters,
|
||||
exportExcel
|
||||
}
|
||||
}
|
||||
})
|
||||
exportExcel,
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
@@ -1,70 +1,70 @@
|
||||
// nuxt 3 - plugins/my-plugin.ts
|
||||
import { useRoute } from 'vue-router';
|
||||
import { useStore } from '~/stores/index';
|
||||
import dayjs from 'dayjs';
|
||||
import weekday from 'dayjs/plugin/weekday';
|
||||
import weekOfYear from 'dayjs/plugin/weekOfYear';
|
||||
import relativeTime from 'dayjs/plugin/relativeTime';
|
||||
import localizedFormat from 'dayjs/plugin/localizedFormat';
|
||||
import isSameOrBefore from 'dayjs/plugin/isSameOrBefore';
|
||||
import isSameOrAfter from 'dayjs/plugin/isSameOrAfter';
|
||||
import 'dayjs/locale/vi';
|
||||
import { useRoute } from "vue-router";
|
||||
import { useStore } from "~/stores/index";
|
||||
import dayjs from "dayjs";
|
||||
import weekday from "dayjs/plugin/weekday";
|
||||
import weekOfYear from "dayjs/plugin/weekOfYear";
|
||||
import relativeTime from "dayjs/plugin/relativeTime";
|
||||
import localizedFormat from "dayjs/plugin/localizedFormat";
|
||||
import isSameOrBefore from "dayjs/plugin/isSameOrBefore";
|
||||
import isSameOrAfter from "dayjs/plugin/isSameOrAfter";
|
||||
import "dayjs/locale/vi";
|
||||
dayjs.extend(weekday);
|
||||
dayjs.extend(weekOfYear);
|
||||
dayjs.extend(relativeTime);
|
||||
dayjs.extend(localizedFormat);
|
||||
dayjs.extend(isSameOrBefore);
|
||||
dayjs.extend(isSameOrAfter);
|
||||
dayjs.locale('vi');
|
||||
dayjs.locale("vi");
|
||||
|
||||
export default defineNuxtPlugin(() => {
|
||||
const route = useRoute();
|
||||
const { $id, $empty } = useNuxtApp();
|
||||
const store = useStore();
|
||||
const dialog = function (content, title, type, duration, width, height, vbind) {
|
||||
content = typeof content === 'string' ? content : JSON.stringify(content);
|
||||
let vtitle = type === 'Success' ? `<span class="has-text-primary">${title}</span>` : title;
|
||||
if (type === 'Error') vtitle = `<span class="has-text-danger">${title}</span>`;
|
||||
content = typeof content === "string" ? content : JSON.stringify(content);
|
||||
let vtitle = type === "Success" ? `<span class="has-text-primary">${title}</span>` : title;
|
||||
if (type === "Error") vtitle = `<span class="has-text-danger">${title}</span>`;
|
||||
let data = {
|
||||
id: $id(),
|
||||
component: `dialog/${type || 'Info'}`,
|
||||
component: `dialog/${type || "Info"}`,
|
||||
vbind: { content: content, duration: duration, vbind: vbind },
|
||||
title: vtitle,
|
||||
width: width || '600px',
|
||||
height: height || '100px',
|
||||
width: width || "600px",
|
||||
height: height || "100px",
|
||||
};
|
||||
store.commit('showmodal', data);
|
||||
store.commit("showmodal", data);
|
||||
};
|
||||
|
||||
const snackbar = function (content, title, type, width, height) {
|
||||
content = typeof content == 'string' ? content : JSON.stringify(content);
|
||||
let vtitle = type === 'Success' ? `<span class="has-text-primary">${title}</span>` : title;
|
||||
if (type === 'Error') vtitle = `<span class="has-text-danger">${title}</span>`;
|
||||
content = typeof content == "string" ? content : JSON.stringify(content);
|
||||
let vtitle = type === "Success" ? `<span class="has-text-primary">${title}</span>` : title;
|
||||
if (type === "Error") vtitle = `<span class="has-text-danger">${title}</span>`;
|
||||
let data = {
|
||||
id: $id(),
|
||||
component: `snackbar/${type || 'Info'}`,
|
||||
component: `snackbar/${type || "Info"}`,
|
||||
vbind: { content: content },
|
||||
title: vtitle,
|
||||
width: width || '600px',
|
||||
height: height || '100px',
|
||||
width: width || "600px",
|
||||
height: height || "100px",
|
||||
};
|
||||
store.commit('snackbar', data);
|
||||
store.commit("snackbar", data);
|
||||
};
|
||||
|
||||
const getLink = function (val) {
|
||||
if (val === undefined || val === null || val === '' || val === '') return '';
|
||||
let json = val.indexOf('{') >= 0 ? JSON.parse(val) : { path: val };
|
||||
if (val === undefined || val === null || val === "" || val === "") return "";
|
||||
let json = val.indexOf("{") >= 0 ? JSON.parse(val) : { path: val };
|
||||
return json;
|
||||
};
|
||||
|
||||
const errPhone = function (phone) {
|
||||
var text = undefined;
|
||||
if ($empty(phone)) {
|
||||
text = 'Số điện thoại di động không được bỏ trống.';
|
||||
text = "Số điện thoại di động không được bỏ trống.";
|
||||
} else if (isNaN(phone)) {
|
||||
text = 'Số điện thoại di động không hợp lệ.';
|
||||
text = "Số điện thoại di động không hợp lệ.";
|
||||
} else if (phone.length < 9 || phone.length > 11) {
|
||||
text = 'Số điện thoại di động phải từ 9-11 số.';
|
||||
text = "Số điện thoại di động phải từ 9-11 số.";
|
||||
}
|
||||
return text;
|
||||
};
|
||||
@@ -74,9 +74,9 @@ export default defineNuxtPlugin(() => {
|
||||
/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
||||
var text = undefined;
|
||||
if ($empty(email)) {
|
||||
text = 'Email không được bỏ trống.';
|
||||
text = "Email không được bỏ trống.";
|
||||
} else if (!re.test(String(email).toLowerCase())) {
|
||||
text = 'Email không hợp lệ.';
|
||||
text = "Email không hợp lệ.";
|
||||
}
|
||||
return text;
|
||||
};
|
||||
@@ -87,11 +87,11 @@ export default defineNuxtPlugin(() => {
|
||||
var text = undefined;
|
||||
|
||||
if ($empty(contact)) {
|
||||
text = 'Số điện thoại di động hoặc Email không được bỏ trống.';
|
||||
text = "Số điện thoại di động hoặc Email không được bỏ trống.";
|
||||
} else if (!(re.test(String(contact).toLowerCase()) || !isNaN(contact))) {
|
||||
text = 'Số điện thoại di động hoặc Email không hợp lệ.';
|
||||
text = "Số điện thoại di động hoặc Email không hợp lệ.";
|
||||
} else if (!isNaN(contact) && (contact.length < 9 || contact.length > 11)) {
|
||||
text = 'Số điện thoại di động không hợp lệ.';
|
||||
text = "Số điện thoại di động không hợp lệ.";
|
||||
}
|
||||
return text;
|
||||
};
|
||||
@@ -106,41 +106,63 @@ export default defineNuxtPlugin(() => {
|
||||
|
||||
const upload = function (file, type, user, convert, quality) {
|
||||
var fileFormat = [
|
||||
{ type: 'image', format: ['.png', '.jpg', 'jpeg', '.bmp', '.gif', '.svg', '.webp'] },
|
||||
{ type: 'video', format: ['.wmv', '.avi', '.mp4', '.flv', '.mov', '.mpg', '.amv', '.rm'] },
|
||||
{
|
||||
type: "image",
|
||||
format: [".png", ".jpg", "jpeg", ".bmp", ".gif", ".svg", ".webp"],
|
||||
},
|
||||
{
|
||||
type: "video",
|
||||
format: [".wmv", ".avi", ".mp4", ".flv", ".mov", ".mpg", ".amv", ".rm"],
|
||||
},
|
||||
];
|
||||
var valid = undefined;
|
||||
if (type === 'image' || type === 'video') {
|
||||
if (type === "image" || type === "video") {
|
||||
valid = false;
|
||||
let found = fileFormat.find((v) => v.type === type);
|
||||
found.format.map((x) => {
|
||||
if (file.name.toLowerCase().indexOf(x) >= 0) valid = true;
|
||||
});
|
||||
}
|
||||
if (valid === false) return { name: file.name, error: true, text: 'Định dạng file không hợp lệ' };
|
||||
if ((type === 'image' || type === 'file') && file.size > 500 * 1024 * 1024) {
|
||||
if (valid === false)
|
||||
return {
|
||||
name: file.name,
|
||||
error: true,
|
||||
text: 'Kích thước ' + (type === 'image' ? 'hình ảnh' : 'tài liệu') + ' phải dưới 500MB',
|
||||
text: "Định dạng file không hợp lệ",
|
||||
};
|
||||
if ((type === "image" || type === "file") && file.size > 500 * 1024 * 1024) {
|
||||
return {
|
||||
name: file.name,
|
||||
error: true,
|
||||
text: "Kích thước " + (type === "image" ? "hình ảnh" : "tài liệu") + " phải dưới 500MB",
|
||||
};
|
||||
} else if (type === "video" && file.size > 1073741274) {
|
||||
return {
|
||||
name: file.name,
|
||||
error: true,
|
||||
text: "Kích thước video phải dưới 1GB",
|
||||
};
|
||||
} else if (type === 'video' && file.size > 1073741274) {
|
||||
return { name: file.name, error: true, text: 'Kích thước video phải dưới 1GB' };
|
||||
}
|
||||
let data = new FormData();
|
||||
let fileName = dayjs(new Date()).format('YYYYMMDDhhmmss') + '-' + file.name;
|
||||
data.append('name', file.name);
|
||||
data.append('filename', fileName);
|
||||
data.append('file', file);
|
||||
data.append('type', type);
|
||||
data.append('size', file.size);
|
||||
data.append('user', user);
|
||||
data.append('convert', convert);
|
||||
let fileName = dayjs(new Date()).format("YYYYMMDDhhmmss") + "-" + file.name;
|
||||
data.append("name", file.name);
|
||||
data.append("filename", fileName);
|
||||
data.append("file", file);
|
||||
data.append("type", type);
|
||||
data.append("size", file.size);
|
||||
data.append("user", user);
|
||||
data.append("convert", convert);
|
||||
// Thêm quality nếu convert được bật và quality được cung cấp
|
||||
if (convert && quality !== null && quality !== undefined) {
|
||||
data.append('quality', quality);
|
||||
data.append("quality", quality);
|
||||
}
|
||||
return { form: data, type: type, size: file.size, file: file, name: file.name, filename: fileName };
|
||||
return {
|
||||
form: data,
|
||||
type: type,
|
||||
size: file.size,
|
||||
file: file,
|
||||
name: file.name,
|
||||
filename: fileName,
|
||||
};
|
||||
};
|
||||
|
||||
const change = function (obj1, obj2, list) {
|
||||
@@ -159,9 +181,9 @@ export default defineNuxtPlugin(() => {
|
||||
|
||||
const resetNull = function (obj) {
|
||||
for (const [key, value] of Object.entries(obj)) {
|
||||
if (typeof value === 'string') {
|
||||
if (typeof value === "string") {
|
||||
let val = value.trim();
|
||||
if (val === '' || val === '') val = null;
|
||||
if (val === "" || val === "") val = null;
|
||||
obj[key] = val;
|
||||
}
|
||||
}
|
||||
@@ -169,20 +191,20 @@ export default defineNuxtPlugin(() => {
|
||||
};
|
||||
|
||||
const copyToClipboard = function (text) {
|
||||
snackbar('Copied to clipboard');
|
||||
snackbar("Copied to clipboard");
|
||||
if (window.clipboardData && window.clipboardData.setData) {
|
||||
// IE specific code path to prevent textarea being shown while dialog is visible.
|
||||
return clipboardData.setData('Text', text);
|
||||
} else if (document.queryCommandSupported && document.queryCommandSupported('copy')) {
|
||||
var textarea = document.createElement('textarea');
|
||||
return clipboardData.setData("Text", text);
|
||||
} else if (document.queryCommandSupported && document.queryCommandSupported("copy")) {
|
||||
var textarea = document.createElement("textarea");
|
||||
textarea.textContent = text;
|
||||
textarea.style.position = 'fixed'; // Prevent scrolling to bottom of page in MS Edge.
|
||||
textarea.style.position = "fixed"; // Prevent scrolling to bottom of page in MS Edge.
|
||||
document.body.appendChild(textarea);
|
||||
textarea.select();
|
||||
try {
|
||||
return document.execCommand('copy'); // Security exception may be thrown by some browsers.
|
||||
return document.execCommand("copy"); // Security exception may be thrown by some browsers.
|
||||
} catch (ex) {
|
||||
console.warn('Copy to clipboard failed.', ex);
|
||||
console.warn("Copy to clipboard failed.", ex);
|
||||
return false;
|
||||
} finally {
|
||||
document.body.removeChild(textarea);
|
||||
@@ -192,61 +214,61 @@ export default defineNuxtPlugin(() => {
|
||||
|
||||
const nonAccent = function (str) {
|
||||
if ($empty(str)) return null;
|
||||
str = str.replaceAll('/', '-').replaceAll('%', '-').replaceAll('?', '-');
|
||||
str = str.replaceAll("/", "-").replaceAll("%", "-").replaceAll("?", "-");
|
||||
str = str.toLowerCase();
|
||||
str = str.replace(/à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ/g, 'a');
|
||||
str = str.replace(/è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ/g, 'e');
|
||||
str = str.replace(/ì|í|ị|ỉ|ĩ/g, 'i');
|
||||
str = str.replace(/ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ/g, 'o');
|
||||
str = str.replace(/ù|ú|ụ|ủ|ũ|ư|ừ|ứ|ự|ử|ữ/g, 'u');
|
||||
str = str.replace(/ỳ|ý|ỵ|ỷ|ỹ/g, 'y');
|
||||
str = str.replace(/đ/g, 'd');
|
||||
str = str.replace(/à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ/g, "a");
|
||||
str = str.replace(/è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ/g, "e");
|
||||
str = str.replace(/ì|í|ị|ỉ|ĩ/g, "i");
|
||||
str = str.replace(/ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ/g, "o");
|
||||
str = str.replace(/ù|ú|ụ|ủ|ũ|ư|ừ|ứ|ự|ử|ữ/g, "u");
|
||||
str = str.replace(/ỳ|ý|ỵ|ỷ|ỹ/g, "y");
|
||||
str = str.replace(/đ/g, "d");
|
||||
// Some system encode vietnamese combining accent as individual utf-8 characters
|
||||
str = str.replace(/\u0300|\u0301|\u0303|\u0309|\u0323/g, ''); // Huyền sắc hỏi ngã nặng
|
||||
str = str.replace(/\u02C6|\u0306|\u031B/g, ''); // Â, Ê, Ă, Ơ, Ư
|
||||
str = str.replace(/\u0300|\u0301|\u0303|\u0309|\u0323/g, ""); // Huyền sắc hỏi ngã nặng
|
||||
str = str.replace(/\u02C6|\u0306|\u031B/g, ""); // Â, Ê, Ă, Ơ, Ư
|
||||
str = str
|
||||
.split(' ')
|
||||
.split(" ")
|
||||
.filter((s) => s)
|
||||
.join('-');
|
||||
.join("-");
|
||||
return str;
|
||||
};
|
||||
|
||||
const linkID = function (link) {
|
||||
link = link ? link : route.params.slug;
|
||||
if ($empty(link)) return;
|
||||
let idx = link.lastIndexOf('-');
|
||||
let idx = link.lastIndexOf("-");
|
||||
let id = idx > -1 && idx < link.length - 1 ? link.substring(idx + 1, link.length) : undefined;
|
||||
return id;
|
||||
};
|
||||
|
||||
const exportpdf = function (docid, name, size, orientation = 'portrait') {
|
||||
const exportpdf = function (docid, name, size, orientation = "portrait") {
|
||||
var element = document.getElementById(docid);
|
||||
let elms = element.querySelectorAll("[id='ignore']");
|
||||
for (var i = 0; i < elms.length; i++) {
|
||||
elms[i].style.setProperty('display', 'none', 'important');
|
||||
elms[i].style.setProperty("display", "none", "important");
|
||||
}
|
||||
// Xóa cache ảnh để lần export sau không bị lỗi
|
||||
element.querySelectorAll('img').forEach((img) => {
|
||||
element.querySelectorAll("img").forEach((img) => {
|
||||
img.src = `${img.src}`;
|
||||
});
|
||||
var opt = {
|
||||
margin: 0.4,
|
||||
filename: `${name || 'file'}-${dayjs().format('YYYYMMDDHHmmss')}.pdf`,
|
||||
image: { type: 'jpeg', quality: 1 },
|
||||
filename: `${name || "file"}-${dayjs().format("YYYYMMDDHHmmss")}.pdf`,
|
||||
image: { type: "jpeg", quality: 1 },
|
||||
html2canvas: { scale: 3, useCORS: true },
|
||||
jsPDF: { unit: 'in', format: size || 'a4', orientation },
|
||||
jsPDF: { unit: "in", format: size || "a4", orientation },
|
||||
|
||||
pagebreak: {
|
||||
mode: ['avoid-all', 'css', 'legacy'],
|
||||
before: '.page-break-before',
|
||||
after: '.page-break-after',
|
||||
avoid: '.avoid-page-break',
|
||||
mode: ["avoid-all", "css", "legacy"],
|
||||
before: ".page-break-before",
|
||||
after: ".page-break-after",
|
||||
avoid: ".avoid-page-break",
|
||||
},
|
||||
};
|
||||
setTimeout(() => html2pdf().set(opt).from(element).save(), 300);
|
||||
setTimeout(() => {
|
||||
for (var i = 0; i < elms.length; i++) {
|
||||
elms[i].style.removeProperty('display');
|
||||
elms[i].style.removeProperty("display");
|
||||
}
|
||||
}, 1000);
|
||||
return opt.filename;
|
||||
@@ -256,58 +278,58 @@ export default defineNuxtPlugin(() => {
|
||||
var element = document.getElementById(docid);
|
||||
let elms = element.querySelectorAll("[id='ignore']");
|
||||
for (var i = 0; i < elms.length; i++) {
|
||||
elms[i].style.display = 'none';
|
||||
elms[i].style.display = "none";
|
||||
}
|
||||
let filename = `${name}-${dayjs().format('YYYYMMDDHHmmss')}.png`;
|
||||
let filename = `${name}-${dayjs().format("YYYYMMDDHHmmss")}.png`;
|
||||
html2canvas(element).then((canvas) => {
|
||||
const link = document.createElement('a');
|
||||
link.href = canvas.toDataURL('image/png');
|
||||
const link = document.createElement("a");
|
||||
link.href = canvas.toDataURL("image/png");
|
||||
link.download = filename;
|
||||
link.click();
|
||||
link.remove();
|
||||
});
|
||||
setTimeout(() => {
|
||||
for (var i = 0; i < elms.length; i++) {
|
||||
elms[i].style.display = 'block';
|
||||
elms[i].style.display = "block";
|
||||
}
|
||||
}, 1000);
|
||||
return filename;
|
||||
};
|
||||
|
||||
const download = async function (url, fileName) {
|
||||
let name = dayjs(new Date()).format('YYYYMMDDhhmmss') + '-' + fileName;
|
||||
const response = await fetch(url, { method: 'GET' });
|
||||
let name = dayjs(new Date()).format("YYYYMMDDhhmmss") + "-" + fileName;
|
||||
const response = await fetch(url, { method: "GET" });
|
||||
const blob = await response.blob();
|
||||
const urlDownload = window.URL.createObjectURL(blob);
|
||||
const link = document.createElement('a');
|
||||
const link = document.createElement("a");
|
||||
link.href = urlDownload;
|
||||
link.setAttribute('download', name);
|
||||
link.setAttribute("download", name);
|
||||
link.click();
|
||||
link.remove();
|
||||
};
|
||||
|
||||
const vnmoney = function (amount) {
|
||||
var readGroup = function (group) {
|
||||
let readDigit = [' Không', ' Một', ' Hai', ' Ba', ' Bốn', ' Năm', ' Sáu', ' Bảy', ' Tám', ' Chín'];
|
||||
var temp = '';
|
||||
if (group == '000') return '';
|
||||
temp = readDigit[parseInt(group.substring(0, 1))] + ' Trăm';
|
||||
if (group.substring(1, 2) == '0')
|
||||
if (group.substring(2, 3) == '0') return temp;
|
||||
let readDigit = [" Không", " Một", " Hai", " Ba", " Bốn", " Năm", " Sáu", " Bảy", " Tám", " Chín"];
|
||||
var temp = "";
|
||||
if (group == "000") return "";
|
||||
temp = readDigit[parseInt(group.substring(0, 1))] + " Trăm";
|
||||
if (group.substring(1, 2) == "0")
|
||||
if (group.substring(2, 3) == "0") return temp;
|
||||
else {
|
||||
temp += ' Lẻ' + readDigit[parseInt(group.substring(2, 3))];
|
||||
temp += " Lẻ" + readDigit[parseInt(group.substring(2, 3))];
|
||||
return temp;
|
||||
}
|
||||
else temp += readDigit[parseInt(group.substring(1, 2))] + ' Mươi';
|
||||
if (group.substring(2, 3) == '5') temp += ' Lăm';
|
||||
else if (group.substring(2, 3) != '0') temp += readDigit[parseInt(group.substring(2, 3))];
|
||||
else temp += readDigit[parseInt(group.substring(1, 2))] + " Mươi";
|
||||
if (group.substring(2, 3) == "5") temp += " Lăm";
|
||||
else if (group.substring(2, 3) != "0") temp += readDigit[parseInt(group.substring(2, 3))];
|
||||
return temp;
|
||||
};
|
||||
var readMoney = function (num) {
|
||||
if (num == null || num == '') return '';
|
||||
let temp = '';
|
||||
if (num == null || num == "") return "";
|
||||
let temp = "";
|
||||
while (num.length < 18) {
|
||||
num = '0' + num;
|
||||
num = "0" + num;
|
||||
}
|
||||
let g1 = num.substring(0, 3);
|
||||
let g2 = num.substring(3, 6);
|
||||
@@ -315,50 +337,50 @@ export default defineNuxtPlugin(() => {
|
||||
let g4 = num.substring(9, 12);
|
||||
let g5 = num.substring(12, 15);
|
||||
let g6 = num.substring(15, 18);
|
||||
if (g1 != '000') {
|
||||
if (g1 != "000") {
|
||||
temp = readGroup(g1);
|
||||
temp += ' Triệu';
|
||||
temp += " Triệu";
|
||||
}
|
||||
if (g2 != '000') {
|
||||
if (g2 != "000") {
|
||||
temp += readGroup(g2);
|
||||
temp += ' Nghìn';
|
||||
temp += " Nghìn";
|
||||
}
|
||||
if (g3 != '000') {
|
||||
if (g3 != "000") {
|
||||
temp += readGroup(g3);
|
||||
temp += ' Tỷ';
|
||||
} else if ('' != temp) {
|
||||
temp += ' Tỷ';
|
||||
temp += " Tỷ";
|
||||
} else if ("" != temp) {
|
||||
temp += " Tỷ";
|
||||
}
|
||||
if (g4 != '000') {
|
||||
if (g4 != "000") {
|
||||
temp += readGroup(g4);
|
||||
temp += ' Triệu';
|
||||
temp += " Triệu";
|
||||
}
|
||||
if (g5 != '000') {
|
||||
if (g5 != "000") {
|
||||
temp += readGroup(g5);
|
||||
temp += ' Nghìn';
|
||||
temp += " Nghìn";
|
||||
}
|
||||
temp = temp + readGroup(g6);
|
||||
temp = temp.replaceAll('Một Mươi', 'Mười');
|
||||
temp = temp.replaceAll("Một Mươi", "Mười");
|
||||
temp = temp.trim();
|
||||
temp = temp.replaceAll('Không Trăm', '');
|
||||
temp = temp.replaceAll("Không Trăm", "");
|
||||
temp = temp.trim();
|
||||
temp = temp.replaceAll('Mười Không', 'Mười');
|
||||
temp = temp.replaceAll("Mười Không", "Mười");
|
||||
temp = temp.trim();
|
||||
temp = temp.replaceAll('Mươi Không', 'Mươi');
|
||||
temp = temp.replaceAll("Mươi Không", "Mươi");
|
||||
temp = temp.trim();
|
||||
if (temp.indexOf('Lẻ') == 0) temp = temp.substring(2);
|
||||
if (temp.indexOf("Lẻ") == 0) temp = temp.substring(2);
|
||||
temp = temp.trim();
|
||||
temp = temp.replaceAll('Mươi Một', 'Mươi Mốt');
|
||||
temp = temp.replaceAll("Mươi Một", "Mươi Mốt");
|
||||
temp = temp.trim();
|
||||
let result = temp.substring(0, 1).toUpperCase() + temp.substring(1).toLowerCase();
|
||||
return (result == '' ? 'Không' : result) + ' đồng chẵn';
|
||||
return (result == "" ? "Không" : result) + " đồng chẵn";
|
||||
};
|
||||
return readMoney(amount.toString());
|
||||
};
|
||||
|
||||
const lang = function (code) {
|
||||
let field = store.common.find((v) => v.code === code);
|
||||
return field ? field[store.lang] : '';
|
||||
return field ? field[store.lang] : "";
|
||||
};
|
||||
|
||||
const createMeta = function (metainfo) {
|
||||
@@ -366,100 +388,100 @@ export default defineNuxtPlugin(() => {
|
||||
title: metainfo.title,
|
||||
link: [
|
||||
{
|
||||
hid: 'canonical',
|
||||
rel: 'canonical',
|
||||
hid: "canonical",
|
||||
rel: "canonical",
|
||||
href: `https://bigdatatech.vn${route.path}`,
|
||||
},
|
||||
],
|
||||
meta: [
|
||||
{
|
||||
hid: 'description',
|
||||
name: 'description',
|
||||
content: metainfo.description || '',
|
||||
hid: "description",
|
||||
name: "description",
|
||||
content: metainfo.description || "",
|
||||
},
|
||||
{
|
||||
hid: 'og:title',
|
||||
property: 'og:title',
|
||||
hid: "og:title",
|
||||
property: "og:title",
|
||||
content: metainfo.title,
|
||||
},
|
||||
{
|
||||
hid: 'og:description',
|
||||
property: 'og:description',
|
||||
content: metainfo.description || '',
|
||||
hid: "og:description",
|
||||
property: "og:description",
|
||||
content: metainfo.description || "",
|
||||
},
|
||||
{
|
||||
hid: 'og:type',
|
||||
property: 'og:type',
|
||||
content: metainfo.type || '',
|
||||
hid: "og:type",
|
||||
property: "og:type",
|
||||
content: metainfo.type || "",
|
||||
},
|
||||
{
|
||||
hid: 'og:image',
|
||||
property: 'og:image',
|
||||
content: metainfo.image || '',
|
||||
hid: "og:image",
|
||||
property: "og:image",
|
||||
content: metainfo.image || "",
|
||||
},
|
||||
{
|
||||
hid: 'og:url',
|
||||
property: 'og:url',
|
||||
hid: "og:url",
|
||||
property: "og:url",
|
||||
content: `https://bigdatatech.vn${route.path}`,
|
||||
},
|
||||
{
|
||||
property: 'og:locale',
|
||||
content: 'vi_VN',
|
||||
property: "og:locale",
|
||||
content: "vi_VN",
|
||||
},
|
||||
{
|
||||
hid: 'fb:app_id',
|
||||
property: 'fb:app_id',
|
||||
content: metainfo.app_id || '549555567061256',
|
||||
hid: "fb:app_id",
|
||||
property: "fb:app_id",
|
||||
content: metainfo.app_id || "549555567061256",
|
||||
},
|
||||
{
|
||||
hid: 'keywords',
|
||||
name: 'keywords',
|
||||
content: metainfo.keywords || '',
|
||||
hid: "keywords",
|
||||
name: "keywords",
|
||||
content: metainfo.keywords || "",
|
||||
},
|
||||
],
|
||||
};
|
||||
};
|
||||
|
||||
const formatFileSize = (bytes) => {
|
||||
if (bytes === 0) return '0 Bytes';
|
||||
if (bytes === 0) return "0 Bytes";
|
||||
const k = 1024;
|
||||
const sizes = ['Bytes', 'KB', 'MB', 'GB'];
|
||||
const sizes = ["Bytes", "KB", "MB", "GB"];
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||
return Math.round((bytes / Math.pow(k, i)) * 100) / 100 + ' ' + sizes[i];
|
||||
return Math.round((bytes / Math.pow(k, i)) * 100) / 100 + " " + sizes[i];
|
||||
};
|
||||
|
||||
const numberToVietnamese = (input) => {
|
||||
if (input === null || input === undefined || input === '') return '';
|
||||
if (input === null || input === undefined || input === "") return "";
|
||||
|
||||
var number = Number(input);
|
||||
if (isNaN(number) || number < 0 || number % 1 !== 0) return '';
|
||||
if (isNaN(number) || number < 0 || number % 1 !== 0) return "";
|
||||
|
||||
if (number === 0) return 'Không';
|
||||
if (number === 0) return "Không";
|
||||
|
||||
var units = ['không', 'một', 'hai', 'ba', 'bốn', 'năm', 'sáu', 'bảy', 'tám', 'chín'];
|
||||
var units = ["không", "một", "hai", "ba", "bốn", "năm", "sáu", "bảy", "tám", "chín"];
|
||||
|
||||
var scales = ['', 'nghìn', 'triệu', 'tỷ', 'nghìn tỷ', 'triệu tỷ'];
|
||||
var scales = ["", "nghìn", "triệu", "tỷ", "nghìn tỷ", "triệu tỷ"];
|
||||
|
||||
function readThreeDigits(num, isFull) {
|
||||
var result = '';
|
||||
var result = "";
|
||||
var hundred = Math.floor(num / 100);
|
||||
var ten = Math.floor((num % 100) / 10);
|
||||
var unit = num % 10;
|
||||
|
||||
if (hundred > 0 || isFull) {
|
||||
result += units[hundred] + ' trăm';
|
||||
if (ten === 0 && unit > 0) result += ' lẻ';
|
||||
result += units[hundred] + " trăm";
|
||||
if (ten === 0 && unit > 0) result += " lẻ";
|
||||
}
|
||||
|
||||
if (ten > 1) {
|
||||
result += ' ' + units[ten] + ' mươi';
|
||||
if (unit === 1) result += ' mốt';
|
||||
else if (unit === 5) result += ' lăm';
|
||||
else if (unit > 0) result += ' ' + units[unit];
|
||||
result += " " + units[ten] + " mươi";
|
||||
if (unit === 1) result += " mốt";
|
||||
else if (unit === 5) result += " lăm";
|
||||
else if (unit > 0) result += " " + units[unit];
|
||||
} else if (ten === 1) {
|
||||
result += ' mười';
|
||||
if (unit === 5) result += ' lăm';
|
||||
else if (unit > 0) result += ' ' + units[unit];
|
||||
result += " mười";
|
||||
if (unit === 5) result += " lăm";
|
||||
else if (unit > 0) result += " " + units[unit];
|
||||
} else if (ten === 0 && unit > 0 && hundred === 0 && !isFull) {
|
||||
result += units[unit];
|
||||
}
|
||||
@@ -467,18 +489,18 @@ export default defineNuxtPlugin(() => {
|
||||
return result.trim();
|
||||
}
|
||||
|
||||
var result = '';
|
||||
var result = "";
|
||||
var scaleIndex = 0;
|
||||
|
||||
while (number > 0) {
|
||||
var chunk = number % 1000;
|
||||
|
||||
if (chunk > 0) {
|
||||
var isFull = result !== '';
|
||||
var isFull = result !== "";
|
||||
result =
|
||||
readThreeDigits(chunk, isFull) +
|
||||
(scales[scaleIndex] ? ' ' + scales[scaleIndex] : '') +
|
||||
(result ? ' ' + result : '');
|
||||
(scales[scaleIndex] ? " " + scales[scaleIndex] : "") +
|
||||
(result ? " " + result : "");
|
||||
}
|
||||
|
||||
number = Math.floor(number / 1000);
|
||||
@@ -490,12 +512,12 @@ export default defineNuxtPlugin(() => {
|
||||
};
|
||||
|
||||
const formatDateVN = (input, { withTime = false, withSeconds = false } = {}) => {
|
||||
if (!input) return '';
|
||||
if (!input) return "";
|
||||
|
||||
const date = new Date(input);
|
||||
if (isNaN(date.getTime())) return '';
|
||||
if (isNaN(date.getTime())) return "";
|
||||
|
||||
const pad = (n) => String(n).padStart(2, '0');
|
||||
const pad = (n) => String(n).padStart(2, "0");
|
||||
|
||||
const day = pad(date.getDate());
|
||||
const month = pad(date.getMonth() + 1);
|
||||
@@ -518,34 +540,34 @@ export default defineNuxtPlugin(() => {
|
||||
};
|
||||
|
||||
const numberToVietnameseCurrency = (amount) => {
|
||||
if (amount === null || amount === undefined || amount === '') return '';
|
||||
if (amount === null || amount === undefined || amount === "") return "";
|
||||
|
||||
amount = Number(amount);
|
||||
if (isNaN(amount)) return '';
|
||||
if (isNaN(amount)) return "";
|
||||
|
||||
const units = ['', 'một', 'hai', 'ba', 'bốn', 'năm', 'sáu', 'bảy', 'tám', 'chín'];
|
||||
const scales = ['', 'nghìn', 'triệu', 'tỷ'];
|
||||
const units = ["", "một", "hai", "ba", "bốn", "năm", "sáu", "bảy", "tám", "chín"];
|
||||
const scales = ["", "nghìn", "triệu", "tỷ"];
|
||||
|
||||
function readThreeDigits(num) {
|
||||
let result = '';
|
||||
let result = "";
|
||||
const hundred = Math.floor(num / 100);
|
||||
const ten = Math.floor((num % 100) / 10);
|
||||
const unit = num % 10;
|
||||
|
||||
if (hundred > 0) {
|
||||
result += units[hundred] + ' trăm';
|
||||
if (ten === 0 && unit > 0) result += ' lẻ';
|
||||
result += units[hundred] + " trăm";
|
||||
if (ten === 0 && unit > 0) result += " lẻ";
|
||||
}
|
||||
|
||||
if (ten > 1) {
|
||||
result += ' ' + units[ten] + ' mươi';
|
||||
if (unit === 1) result += ' mốt';
|
||||
else if (unit === 5) result += ' lăm';
|
||||
else if (unit > 0) result += ' ' + units[unit];
|
||||
result += " " + units[ten] + " mươi";
|
||||
if (unit === 1) result += " mốt";
|
||||
else if (unit === 5) result += " lăm";
|
||||
else if (unit > 0) result += " " + units[unit];
|
||||
} else if (ten === 1) {
|
||||
result += ' mười';
|
||||
if (unit === 5) result += ' lăm';
|
||||
else if (unit > 0) result += ' ' + units[unit];
|
||||
result += " mười";
|
||||
if (unit === 5) result += " lăm";
|
||||
else if (unit > 0) result += " " + units[unit];
|
||||
} else if (ten === 0 && unit > 0 && hundred === 0) {
|
||||
result += units[unit];
|
||||
}
|
||||
@@ -553,7 +575,7 @@ export default defineNuxtPlugin(() => {
|
||||
return result.trim();
|
||||
}
|
||||
|
||||
let text = '';
|
||||
let text = "";
|
||||
let scaleIndex = 0;
|
||||
|
||||
while (amount > 0) {
|
||||
@@ -572,30 +594,30 @@ export default defineNuxtPlugin(() => {
|
||||
};
|
||||
|
||||
const getFirstAndLastName = (fullName, showDots) => {
|
||||
if (!fullName) return '';
|
||||
if (!fullName) return "";
|
||||
|
||||
var parts = fullName.trim().replace(/\s+/g, ' ').split(' ');
|
||||
var parts = fullName.trim().replace(/\s+/g, " ").split(" ");
|
||||
|
||||
if (parts.length === 1) return parts[0];
|
||||
|
||||
var first = parts[0];
|
||||
var last = parts[parts.length - 1];
|
||||
|
||||
return showDots ? first + '...' + last : first + ' ' + last;
|
||||
return showDots ? first + "..." + last : first + " " + last;
|
||||
};
|
||||
|
||||
const paymentQR = (content = '', bankCode = 'MB', amount = 0) => {
|
||||
const paymentQR = (content = "", bankCode = "MB", amount = 0) => {
|
||||
const listBanks = [
|
||||
{
|
||||
bank: {
|
||||
code: 'MB',
|
||||
name: 'MB Bank',
|
||||
code: "MB",
|
||||
name: "MB Bank",
|
||||
},
|
||||
account: {
|
||||
number: '146768686868',
|
||||
name: 'CONG TY CO PHAN BAT DONG SAN UTOPIA',
|
||||
number: "146768686868",
|
||||
name: "CONG TY CO PHAN BAT DONG SAN UTOPIA",
|
||||
},
|
||||
content: 'Thanh toán hóa đơn',
|
||||
content: "Thanh toán hóa đơn",
|
||||
},
|
||||
];
|
||||
|
||||
@@ -607,18 +629,16 @@ export default defineNuxtPlugin(() => {
|
||||
|
||||
const params = new URLSearchParams({
|
||||
addInfo: content || bankInfo.content,
|
||||
accountName: bankInfo.account.name || '',
|
||||
accountName: bankInfo.account.name || "",
|
||||
amount: amount || 0,
|
||||
});
|
||||
return `https://img.vietqr.io/image/${bankInfo.bank.code}-${bankInfo.account.number}-print.png?${params.toString()}`;
|
||||
};
|
||||
|
||||
function shortenCurrency(amount) {
|
||||
return new Intl.NumberFormat('en', { notation: 'compact' }).format(
|
||||
Number(amount),
|
||||
);
|
||||
return new Intl.NumberFormat("en", { notation: "compact" }).format(Number(amount));
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
provide: {
|
||||
dialog,
|
||||
@@ -647,7 +667,7 @@ export default defineNuxtPlugin(() => {
|
||||
formatDateVN,
|
||||
getFirstAndLastName,
|
||||
paymentQR,
|
||||
shortenCurrency
|
||||
shortenCurrency,
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
@@ -13,18 +13,35 @@ export default defineNuxtPlugin(() => {
|
||||
];
|
||||
const path = paths.find((v) => v.name === mode).url;
|
||||
const apis = [
|
||||
{ name: 'sendemail', url: 'send-email/' },
|
||||
{ name: 'deleteentry', url: 'delete-entry/' },
|
||||
{ name: 'emailpreview', url: 'email-preview/' },
|
||||
{ name: 'workflow', url: 'workflow/execute/' },
|
||||
{ name: 'accountentry', url: 'account-entry/', params: {} },
|
||||
{ name: 'accountmultientry', url: 'account-multi-entry/', params: {} },
|
||||
{ name: 'entryfile', url: 'data/Entry_File/', url_detail: 'data-detail/Entry_File/', params: { values: 'id,file__file,file__name,file__caption,file,file__user__fullname,create_time' } },
|
||||
{ name: 'importsetting', url: 'data/Import_Setting/', url_detail: 'data-detail/Import_Setting/', params: {} },
|
||||
{ name: 'modelfields', url: 'model-fields/', params: {} },
|
||||
{ name: 'readexcel', url: 'read-excel/', params: {} },
|
||||
{ name: 'findkey', url: 'find-key/', params: {} },
|
||||
{ name: 'dealerrights', url: 'data/Biz_Rights/', url_detail: 'data-detail/Biz_Rights/', params: { sort: '-id' } },
|
||||
{ name: "sendemail", url: "send-email/" },
|
||||
{ name: "deleteentry", url: "delete-entry/" },
|
||||
{ name: "emailpreview", url: "email-preview/" },
|
||||
{ name: "workflow", url: "workflow/execute/" },
|
||||
{ name: "accountentry", url: "account-entry/", params: {} },
|
||||
{ name: "accountmultientry", url: "account-multi-entry/", params: {} },
|
||||
{
|
||||
name: "entryfile",
|
||||
url: "data/Entry_File/",
|
||||
url_detail: "data-detail/Entry_File/",
|
||||
params: {
|
||||
values: "id,file__file,file__name,file__caption,file,file__user__fullname,create_time",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "importsetting",
|
||||
url: "data/Import_Setting/",
|
||||
url_detail: "data-detail/Import_Setting/",
|
||||
params: {},
|
||||
},
|
||||
{ name: "modelfields", url: "model-fields/", params: {} },
|
||||
{ name: "readexcel", url: "read-excel/", params: {} },
|
||||
{ name: "findkey", url: "find-key/", params: {} },
|
||||
{
|
||||
name: "dealerrights",
|
||||
url: "data/Biz_Rights/",
|
||||
url_detail: "data-detail/Biz_Rights/",
|
||||
params: { sort: "-id" },
|
||||
},
|
||||
{
|
||||
name: "individual",
|
||||
url: "data/Individual/",
|
||||
@@ -39,8 +56,9 @@ export default defineNuxtPlugin(() => {
|
||||
url: "data/Transaction_Discount/",
|
||||
url_detail: "data-detail/Transaction_Discount/",
|
||||
params: {
|
||||
values: "id,transaction,discount,discount__code,discount__name,type,type__code,type__name,value,create_time,update_time"
|
||||
}
|
||||
values:
|
||||
"id,transaction,discount,discount__code,discount__name,type,type__code,type__name,value,create_time,update_time",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "organization",
|
||||
@@ -56,8 +74,8 @@ export default defineNuxtPlugin(() => {
|
||||
url: "data/Co_Ownership/",
|
||||
url_detail: "data-detail/Co_Ownership/",
|
||||
params: {
|
||||
values: 'id,transaction,people,people__code,people__fullname,people__phone,people__legal_code'
|
||||
}
|
||||
values: "id,transaction,people,people__code,people__fullname,people__phone,people__legal_code",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "companytype",
|
||||
@@ -71,18 +89,18 @@ export default defineNuxtPlugin(() => {
|
||||
name: "cart",
|
||||
url: "data/Cart/",
|
||||
url_detail: "data-detail/Cart/",
|
||||
commit: 'cart',
|
||||
commit: "cart",
|
||||
params: {
|
||||
sort: "id",
|
||||
values: "id,code,name,dealer,dealer__code,dealer__name,create_time",
|
||||
distinct_values: {
|
||||
label: {
|
||||
type: "Concat",
|
||||
field: ["code", "name"]
|
||||
}
|
||||
field: ["code", "name"],
|
||||
},
|
||||
},
|
||||
summary: "annotate",
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "payment_schedule",
|
||||
@@ -91,7 +109,7 @@ export default defineNuxtPlugin(() => {
|
||||
params: {
|
||||
sort: "-id",
|
||||
values:
|
||||
"batch_date,amount_remain,penalty_remain,penalty_paid,penalty_amount,penalty_reduce,ovd_days,remain_amount,paid_amount,txn_detail__transaction__product__trade_code,txn_detail__status,txn_detail__transaction__product__code,txn_detail__phase__name,txn_detail,id,txn_detail__transaction__customer__fullname,txn_detail__transaction__customer__code,txn_detail__transaction__customer__legal_code,status__name,type__name,code,from_date,txn_detail__transaction__policy__code,to_date,amount,cycle,cycle_days,txn_detail__transaction,type,status,updater,entry,detail,txn_detail__transaction__code,txn_detail__code"
|
||||
"batch_date,amount_remain,penalty_remain,penalty_paid,penalty_amount,penalty_reduce,ovd_days,remain_amount,paid_amount,txn_detail__transaction__product__trade_code,txn_detail__status,txn_detail__transaction__product__code,txn_detail__phase__name,txn_detail,id,txn_detail__transaction__customer__fullname,txn_detail__transaction__customer__code,txn_detail__transaction__customer__legal_code,status__name,type__name,code,from_date,txn_detail__transaction__policy__code,to_date,amount,cycle,cycle_days,txn_detail__transaction,type,status,updater,entry,detail,txn_detail__transaction__code,txn_detail__code",
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -109,22 +127,78 @@ export default defineNuxtPlugin(() => {
|
||||
summary: "annotate",
|
||||
},
|
||||
},
|
||||
{ name: 'productnote', url: 'data/Product_Note/', url_detail: 'data-detail/Product_Note/', commit: 'productnote', params: {sort: 'id',values: 'id,detail,user,user__username,user__fullname,create_time,update_time,ref,ref__cart__dealer,ref__trade_code' } },
|
||||
{
|
||||
name:"customernote",
|
||||
{
|
||||
name: "productnote",
|
||||
url: "data/Product_Note/",
|
||||
url_detail: "data-detail/Product_Note/",
|
||||
commit: "productnote",
|
||||
params: {
|
||||
sort: "id",
|
||||
values:
|
||||
"id,detail,user,user__username,user__fullname,create_time,update_time,ref,ref__cart__dealer,ref__trade_code",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "customernote",
|
||||
url: "data/Customer_Note/",
|
||||
url_detail: "data-detail/Customer_Note/",
|
||||
params: {
|
||||
values: 'id,ref,detail,user,create_time,update_time'
|
||||
}
|
||||
values: "id,ref,detail,user,create_time,update_time",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "entrytype",
|
||||
url: "data/Entry_Type/",
|
||||
url_detail: "data-detail/Entry_Type/",
|
||||
params: {},
|
||||
},
|
||||
{
|
||||
name: "entrycategory",
|
||||
url: "data/Entry_Category/",
|
||||
url_detail: "data-detail/Entry_Category/",
|
||||
params: {},
|
||||
},
|
||||
{
|
||||
name: "accounttype",
|
||||
url: "data/Account_Type/",
|
||||
url_detail: "data-detail/Account_Type/",
|
||||
params: { sort: "id" },
|
||||
},
|
||||
{
|
||||
name: "internalaccount",
|
||||
url: "data/Internal_Account/",
|
||||
url_detail: "data-detail/Internal_Account/",
|
||||
params: {
|
||||
sort: "branch,currency,type",
|
||||
values:
|
||||
"id,currency,currency__code,currency__name,code,balance,create_time,update_time,type,type__code,type__name,branch,branch__code,branch__name",
|
||||
distinct_values: {
|
||||
label: {
|
||||
type: "Concat",
|
||||
field: ["branch__name", "code", "type__name"],
|
||||
},
|
||||
},
|
||||
summary: "annotate",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "currency",
|
||||
url: "data/Currency/",
|
||||
url_detail: "data-detail/Currency/",
|
||||
params: {},
|
||||
},
|
||||
{
|
||||
name: "approvestatus",
|
||||
url: "data/Approve_Status/",
|
||||
url_detail: "data-detail/Approve_Status/",
|
||||
params: {},
|
||||
},
|
||||
{
|
||||
name: "bizrights",
|
||||
url: "data/Biz_Rights/",
|
||||
url_detail: "data-detail/Biz_Rights/",
|
||||
params: { sort: "-id" },
|
||||
},
|
||||
{ name: 'entrytype', url: 'data/Entry_Type/', url_detail: 'data-detail/Entry_Type/', params: {} },
|
||||
{ name: 'entrycategory', url: 'data/Entry_Category/', url_detail: 'data-detail/Entry_Category/', params: {} },
|
||||
{ name: 'accounttype', url: 'data/Account_Type/', url_detail: 'data-detail/Account_Type/', params: { sort: 'id' } },
|
||||
{ name: 'internalaccount', url: 'data/Internal_Account/', url_detail: 'data-detail/Internal_Account/', params: { sort: 'branch,currency,type', values: 'id,currency,currency__code,currency__name,code,balance,create_time,update_time,type,type__code,type__name,branch,branch__code,branch__name', distinct_values: { label: { type: 'Concat', field: ['branch__name', 'code', 'type__name'] } }, summary: 'annotate' } },
|
||||
{ name: "currency", url: "data/Currency/", url_detail: "data-detail/Currency/", params: {} },
|
||||
{ name: "approvestatus", url: "data/Approve_Status/", url_detail: "data-detail/Approve_Status/", params: {} },
|
||||
{ name: 'bizrights', url: 'data/Biz_Rights/', url_detail: 'data-detail/Biz_Rights/', params: { sort: '-id' } },
|
||||
{
|
||||
name: "feetype",
|
||||
url: "data/Fee_Type/",
|
||||
@@ -194,9 +268,24 @@ export default defineNuxtPlugin(() => {
|
||||
values: "id,code,name,create_time",
|
||||
},
|
||||
},
|
||||
{ name: "image", url: "data/Image/", url_detail: "data-detail/Image/", params: {} },
|
||||
{ name: "file", url: "data/File/", url_detail: "data-detail/File/", params: {} },
|
||||
{ name: "filetype", url: "data/File_Type/", url_detail: "data-detail/File_Type/", params: {} },
|
||||
{
|
||||
name: "image",
|
||||
url: "data/Image/",
|
||||
url_detail: "data-detail/Image/",
|
||||
params: {},
|
||||
},
|
||||
{
|
||||
name: "file",
|
||||
url: "data/File/",
|
||||
url_detail: "data-detail/File/",
|
||||
params: {},
|
||||
},
|
||||
{
|
||||
name: "filetype",
|
||||
url: "data/File_Type/",
|
||||
url_detail: "data-detail/File_Type/",
|
||||
params: {},
|
||||
},
|
||||
{
|
||||
name: "news",
|
||||
commit: "updateNews",
|
||||
@@ -216,7 +305,7 @@ export default defineNuxtPlugin(() => {
|
||||
url: "data/Contract/",
|
||||
url_detail: "data-detail/Contract/",
|
||||
params: {
|
||||
sort: "-id"
|
||||
sort: "-id",
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -270,24 +359,64 @@ export default defineNuxtPlugin(() => {
|
||||
values: "id,code,name,en,index,create_time",
|
||||
},
|
||||
},
|
||||
{ name: "paymentmethod", url: "data/Payment_Method/", url_detail: "data-detail/Payment_Method/", params: {} },
|
||||
{ name: "salepolicy", url: "data/Sale_Policy/", url_detail: "data-detail/Sale_Policy/", params: { values: "id,code,name,deposit,method,method__code,method__name,create_time,enable,contract_allocation_percentage,create_time,update_time,index", sort: "index" } },
|
||||
{
|
||||
name: "paymentmethod",
|
||||
url: "data/Payment_Method/",
|
||||
url_detail: "data-detail/Payment_Method/",
|
||||
params: {},
|
||||
},
|
||||
{
|
||||
name: "salepolicy",
|
||||
url: "data/Sale_Policy/",
|
||||
url_detail: "data-detail/Sale_Policy/",
|
||||
params: {
|
||||
values:
|
||||
"id,code,name,deposit,method,method__code,method__name,create_time,enable,contract_allocation_percentage,create_time,update_time,index",
|
||||
sort: "index",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "paymentplan",
|
||||
url: "data/Payment_Plan/",
|
||||
url_detail: "data-detail/Payment_Plan/",
|
||||
params: {
|
||||
values: "policy__enable,id,policy,policy__code,policy__name,cycle,value,type,days,payment_note,due_note,create_time,update_time",
|
||||
sort: "cycle"
|
||||
values:
|
||||
"policy__enable,id,policy,policy__code,policy__name,cycle,value,type,days,payment_note,due_note,create_time,update_time",
|
||||
sort: "cycle",
|
||||
},
|
||||
},
|
||||
{ name: "request", url: "data/Request/", url_detail: "data-detail/Request/", params: {} },
|
||||
{ name: "register", url: "data/Register/", url_detail: "data-detail/Register/", params: {} },
|
||||
{
|
||||
name: "request",
|
||||
url: "data/Request/",
|
||||
url_detail: "data-detail/Request/",
|
||||
params: {},
|
||||
},
|
||||
{
|
||||
name: "register",
|
||||
url: "data/Register/",
|
||||
url_detail: "data-detail/Register/",
|
||||
params: {},
|
||||
},
|
||||
{ name: "sendemail", url: "send-email/", path: "etl", params: {} },
|
||||
{ name: "sendemailnow", url: "send-email-now/", path: "etl", params: {} },
|
||||
{ name: "usersession", url: "data/User_Session/", url_detail: "data-detail/User_Session/", params: {} },
|
||||
{ name: "userlog", url: "data/User_Log/", url_detail: "data-detail/User_Log/", params: {} },
|
||||
{ name: "usersetting", url: "data/User_Setting/", url_detail: "data-detail/User_Setting/", params: {} },
|
||||
{
|
||||
name: "usersession",
|
||||
url: "data/User_Session/",
|
||||
url_detail: "data-detail/User_Session/",
|
||||
params: {},
|
||||
},
|
||||
{
|
||||
name: "userlog",
|
||||
url: "data/User_Log/",
|
||||
url_detail: "data-detail/User_Log/",
|
||||
params: {},
|
||||
},
|
||||
{
|
||||
name: "usersetting",
|
||||
url: "data/User_Setting/",
|
||||
url_detail: "data-detail/User_Setting/",
|
||||
params: {},
|
||||
},
|
||||
{ name: "account-entry", url: "/account-entry/", params: {} },
|
||||
{
|
||||
name: "valuetype",
|
||||
@@ -295,7 +424,7 @@ export default defineNuxtPlugin(() => {
|
||||
url_detail: "data-detail/Value_Type/",
|
||||
params: {
|
||||
values: "id,code,name,en,index,create_time",
|
||||
sort: "index"
|
||||
sort: "index",
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -311,7 +440,7 @@ export default defineNuxtPlugin(() => {
|
||||
url: "data/Discount_Type/",
|
||||
url_detail: "data-detail/Discount_Type/",
|
||||
params: {
|
||||
values: 'id,code,name,value,type,type__name,method,method__name',
|
||||
values: "id,code,name,value,type,type__name,method,method__name",
|
||||
distinct_values: {
|
||||
label: { type: "Concat", field: ["code", "name", "type__name"] },
|
||||
},
|
||||
@@ -326,14 +455,53 @@ export default defineNuxtPlugin(() => {
|
||||
values:
|
||||
"id,update_time,creator,creator__fullname,country,country__name,country__en,issued_date,issued_place,issued_place__name,code,email,fullname,legal_code,phone,legal_type,legal_type__name,address,contact_address,note,type,type__name,updater,updater__fullname,create_time,update_time",
|
||||
distinct_values: {
|
||||
label: { type: "Concat", field: ["code", "fullname", "phone", "legal_code"] },
|
||||
label: {
|
||||
type: "Concat",
|
||||
field: ["code", "fullname", "phone", "legal_code"],
|
||||
},
|
||||
order: { type: "RowNumber" },
|
||||
image_count: { type: "Count", field: "id", subquery: { model: "Customer_File", column: "ref" } },
|
||||
count_note: { type: "Count", field: "id", subquery: { model: "Customer_Note", column: "ref" } },
|
||||
count_product: { type: "Count", field: "id", subquery: { model: "Product_Booked", column: "transaction__customer" } },
|
||||
sum_product: { type: "Sum", field: "transaction__sale_price", subquery: { model: "Product_Booked", column: "transaction__customer" } },
|
||||
sum_receiver: { type: "Sum", field: "transaction__amount_received", subquery: { model: "Product_Booked", column: "transaction__customer" } },
|
||||
sum_remain: { type: "Sum", field: "transaction__amount_remain", subquery: { model: "Product_Booked", column: "transaction__customer" } }
|
||||
image_count: {
|
||||
type: "Count",
|
||||
field: "id",
|
||||
subquery: { model: "Customer_File", column: "ref" },
|
||||
},
|
||||
count_note: {
|
||||
type: "Count",
|
||||
field: "id",
|
||||
subquery: { model: "Customer_Note", column: "ref" },
|
||||
},
|
||||
count_product: {
|
||||
type: "Count",
|
||||
field: "id",
|
||||
subquery: {
|
||||
model: "Product_Booked",
|
||||
column: "transaction__customer",
|
||||
},
|
||||
},
|
||||
sum_product: {
|
||||
type: "Sum",
|
||||
field: "transaction__sale_price",
|
||||
subquery: {
|
||||
model: "Product_Booked",
|
||||
column: "transaction__customer",
|
||||
},
|
||||
},
|
||||
sum_receiver: {
|
||||
type: "Sum",
|
||||
field: "transaction__amount_received",
|
||||
subquery: {
|
||||
model: "Product_Booked",
|
||||
column: "transaction__customer",
|
||||
},
|
||||
},
|
||||
sum_remain: {
|
||||
type: "Sum",
|
||||
field: "transaction__amount_remain",
|
||||
subquery: {
|
||||
model: "Product_Booked",
|
||||
column: "transaction__customer",
|
||||
},
|
||||
},
|
||||
},
|
||||
summary: "annotate",
|
||||
filter: { deleted: 0 },
|
||||
@@ -346,9 +514,10 @@ export default defineNuxtPlugin(() => {
|
||||
url: "data/Transaction/",
|
||||
url_detail: "data-detail/Transaction/",
|
||||
params: {
|
||||
sort: '-date',
|
||||
values: "date,txncurrent__detail,txncurrent__detail__status,customer__type,txncurrent,txncurrent__detail__amount,txncurrent__detail__amount_remaining,txncurrent__detail__status__name,product__zone_type__name,product__trade_code,product__cart__dealer,customer__legal_code,customer__legal_type__name,payment_plan,id,code,customer,customer__code,customer__fullname,customer__phone,product,phase,phase__name,phase__code,policy,policy__code,policy__name,origin_price,discount_amount,sale_price,deposit_amount,deposit_received,deposit_remaining,amount_received,amount_remain,create_time,update_time"
|
||||
}
|
||||
sort: "-date",
|
||||
values:
|
||||
"date,txncurrent__detail,txncurrent__detail__status,customer__type,txncurrent,txncurrent__detail__amount,txncurrent__detail__amount_remaining,txncurrent__detail__status__name,product__zone_type__name,product__trade_code,product__cart__dealer,customer__legal_code,customer__legal_type__name,payment_plan,id,code,customer,customer__code,customer__fullname,customer__phone,product,phase,phase__name,phase__code,policy,policy__code,policy__name,origin_price,discount_amount,sale_price,deposit_amount,deposit_received,deposit_remaining,amount_received,amount_remain,create_time,update_time",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "transactionphase",
|
||||
@@ -364,8 +533,8 @@ export default defineNuxtPlugin(() => {
|
||||
url_detail: "data-detail/Phase_Doctype/",
|
||||
params: {
|
||||
values: "id,phase,doctype,doctype__code,doctype__name",
|
||||
sort:"doctype__index"
|
||||
}
|
||||
sort: "doctype__index",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "transactiontype",
|
||||
@@ -381,7 +550,8 @@ export default defineNuxtPlugin(() => {
|
||||
url: "data/Transaction_Detail/",
|
||||
url_detail: "data-detail/Transaction_Detail/",
|
||||
params: {
|
||||
values: "id,code,date,amount,amount_received,amount_remaining,phase,due_date,transaction,creator,status,approver,approve_time,create_time,update_time",
|
||||
values:
|
||||
"id,code,date,amount,amount_received,amount_remaining,phase,due_date,transaction,creator,status,approver,approve_time,create_time,update_time",
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -398,8 +568,7 @@ export default defineNuxtPlugin(() => {
|
||||
commit: "productbooked",
|
||||
url: "data/Product_Booked/",
|
||||
url_detail: "data-detail/Product_Booked/",
|
||||
params: {
|
||||
},
|
||||
params: {},
|
||||
},
|
||||
{
|
||||
name: "product",
|
||||
@@ -411,8 +580,11 @@ export default defineNuxtPlugin(() => {
|
||||
values:
|
||||
"prdbk__transaction__amount_remain,prdbk__transaction,price_excluding_vat,prdbk__transaction__txncurrent__detail__status__name,locked_until,note,cart,cart__name,cart__code,cart__dealer,cart__dealer__code,cart__dealer__name,direction,type,zone_type,dealer,link,type__name,dealer__code,dealer__name,prdbk,prdbk__transaction__customer,prdbk__transaction,prdbk__transaction__policy__code,prdbk__transaction__sale_price,prdbk__transaction__discount_amount,prdbk__transaction__code,prdbk__transaction__customer__code,prdbk__transaction__customer__phone,prdbk__transaction__customer__fullname,prdbk__transaction__customer__legal_code,id,code,trade_code,land_lot_code,zone_code,zone_type__name,lot_area,building_area,total_built_area,number_of_floors,land_lot_size,origin_price,direction__name,villa_model,product_type,template_name,project,project__name,status,status__code,status__name,status__color,status__sale_status,status__sale_status__color,create_time,prdbk__transaction__amount_received",
|
||||
distinct_values: {
|
||||
label: { type: "Concat", field: ["trade_code", "type__name", "land_lot_size", "zone_type__name", "status__name"] },
|
||||
count_note: { type: 'Count', field: 'prdnote' }
|
||||
label: {
|
||||
type: "Concat",
|
||||
field: ["trade_code", "type__name", "land_lot_size", "zone_type__name", "status__name"],
|
||||
},
|
||||
count_note: { type: "Count", field: "prdnote" },
|
||||
},
|
||||
summary: "annotate",
|
||||
},
|
||||
@@ -491,7 +663,9 @@ export default defineNuxtPlugin(() => {
|
||||
sort: "-id",
|
||||
values:
|
||||
"id,auth_method__code,blocked,auth_status__code,username,register_method__code,fullname,type,type__code,type__name,create_time,create_time__date,auth_method,auth_status,register_method,create_time,update_time",
|
||||
distinct_values: { label: { type: "Concat", field: ["username", "fullname"] } },
|
||||
distinct_values: {
|
||||
label: { type: "Concat", field: ["username", "fullname"] },
|
||||
},
|
||||
summary: "annotate",
|
||||
},
|
||||
},
|
||||
@@ -616,8 +790,20 @@ export default defineNuxtPlugin(() => {
|
||||
url_detail: "data-detail/Legal_Type/",
|
||||
params: { page: -1 },
|
||||
},
|
||||
{ name: "sex", commit: "sex", url: "data/Sex/", url_detail: "data-detail/Sex/", params: {} },
|
||||
{ name: "usertype", commit: "UserType", url: "data/User_Type/", url_detail: "data-detail/User_Type/", params: {} },
|
||||
{
|
||||
name: "sex",
|
||||
commit: "sex",
|
||||
url: "data/Sex/",
|
||||
url_detail: "data-detail/Sex/",
|
||||
params: {},
|
||||
},
|
||||
{
|
||||
name: "usertype",
|
||||
commit: "UserType",
|
||||
url: "data/User_Type/",
|
||||
url_detail: "data-detail/User_Type/",
|
||||
params: {},
|
||||
},
|
||||
|
||||
{
|
||||
name: "executionmethod",
|
||||
@@ -702,8 +888,18 @@ export default defineNuxtPlugin(() => {
|
||||
"id,country,website,email,code,phone,shortname,fullname,address,create_time,update_time,creator,creator__fullname,updater,updater__fullname",
|
||||
},
|
||||
},
|
||||
{ name: "exportlog", url: "data/Export_Log/", url_detail: "data-detail/Export_Log/", params: {} },
|
||||
{ name: "bank", url: "data/Bank/", url_detail: "data-detail/Bank/", params: {} },
|
||||
{
|
||||
name: "exportlog",
|
||||
url: "data/Export_Log/",
|
||||
url_detail: "data-detail/Export_Log/",
|
||||
params: {},
|
||||
},
|
||||
{
|
||||
name: "bank",
|
||||
url: "data/Bank/",
|
||||
url_detail: "data-detail/Bank/",
|
||||
params: {},
|
||||
},
|
||||
{ name: "exportcsv", url: "exportcsv/", params: {} },
|
||||
{
|
||||
name: "internalentry",
|
||||
@@ -750,13 +946,16 @@ export default defineNuxtPlugin(() => {
|
||||
name: "dealer",
|
||||
url: "data/Dealer/",
|
||||
url_detail: "data-detail/Dealer/",
|
||||
params: { values: "id,count_sale,code,name,phone,address,email,create_time,sale_amount,pay_sale,commission_amount,pay_commission,commission_remain,batch_date" },
|
||||
params: {
|
||||
values:
|
||||
"id,count_sale,code,name,phone,address,email,create_time,sale_amount,pay_sale,commission_amount,pay_commission,commission_remain,batch_date",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "layersetting",
|
||||
url: "data/Layer_Setting/",
|
||||
url_detail: "data-detail/Layer_Setting/",
|
||||
params: { values: "id,code,name,detail,user,create_time,update_time" }
|
||||
params: { values: "id,code,name,detail,user,create_time,update_time" },
|
||||
},
|
||||
{
|
||||
name: "grouprights",
|
||||
@@ -764,29 +963,29 @@ export default defineNuxtPlugin(() => {
|
||||
url: "data/Group_Rights/",
|
||||
url_detail: "data-detail/Group_Rights/",
|
||||
params: {
|
||||
values: 'id,setting,setting__vi,setting__code,setting__category,group,group__name,is_edit,create_time',
|
||||
sort: '-id'
|
||||
values: "id,setting,setting__vi,setting__code,setting__category,group,group__name,is_edit,create_time",
|
||||
sort: "-id",
|
||||
},
|
||||
},
|
||||
{
|
||||
{
|
||||
name: "discountmethod",
|
||||
commit: "discountmethod",
|
||||
url: "data/Discount_Method/",
|
||||
url_detail: "data-detail/Discount_Method/",
|
||||
params: {sort: '-id'},
|
||||
params: { sort: "-id" },
|
||||
},
|
||||
{
|
||||
name: "emailtemplate",
|
||||
url: "data/Email_Template/",
|
||||
url_detail: "data-detail/Email_Template/",
|
||||
params: { values: "id,name,content,create_time,update_time" }
|
||||
{
|
||||
name: "emailtemplate",
|
||||
url: "data/Email_Template/",
|
||||
url_detail: "data-detail/Email_Template/",
|
||||
params: { values: "id,name,content,create_time,update_time" },
|
||||
},
|
||||
{
|
||||
name: "gift",
|
||||
commit: "gift",
|
||||
url: "data/Gift/",
|
||||
url_detail: "data-detail/Gift/",
|
||||
params: {sort: '-id'},
|
||||
params: { sort: "-id" },
|
||||
},
|
||||
{
|
||||
name: "transactiongift",
|
||||
@@ -869,7 +1068,10 @@ export default defineNuxtPlugin(() => {
|
||||
let found = findapi(name);
|
||||
let curpath = found.path ? paths.find((x) => x.name === found.path).url : path;
|
||||
var rs;
|
||||
if (!Array.isArray(data)) rs = await axios.post(`${curpath}${found.url}`, data, { params: { values: values } });
|
||||
if (!Array.isArray(data))
|
||||
rs = await axios.post(`${curpath}${found.url}`, data, {
|
||||
params: { values: values },
|
||||
});
|
||||
else {
|
||||
let params = { action: "import", values: values };
|
||||
rs = await axios.post(`${curpath}import-data/${found.url.substring(5, found.url.length - 1)}/`, data, {
|
||||
@@ -1051,7 +1253,7 @@ export default defineNuxtPlugin(() => {
|
||||
return;
|
||||
}
|
||||
|
||||
const urlParts = apiConfig.url.split('/').filter(p => p);
|
||||
const urlParts = apiConfig.url.split("/").filter((p) => p);
|
||||
// Capitalize the model name for the backend consumer
|
||||
const modelName = urlParts.length > 1 ? urlParts[1].charAt(0).toUpperCase() + urlParts[1].slice(1) : null;
|
||||
|
||||
@@ -1063,7 +1265,7 @@ export default defineNuxtPlugin(() => {
|
||||
const params = $clone(apiConfig.params) || {};
|
||||
|
||||
// List of parameters that need to be stringified if they are objects
|
||||
const paramsToJSONify = ['filter_or', 'exclude', 'distinct_values', 'calculation', 'final_filter', 'final_exclude'];
|
||||
const paramsToJSONify = ["filter_or", "exclude", "distinct_values", "calculation", "final_filter", "final_exclude"];
|
||||
|
||||
// Apply the filter passed to subscribe function
|
||||
if (filter) {
|
||||
@@ -1072,14 +1274,14 @@ export default defineNuxtPlugin(() => {
|
||||
|
||||
// Stringify other dictionary-like parameters if they exist and are objects
|
||||
for (const key of paramsToJSONify) {
|
||||
if (params[key] && typeof params[key] === 'object' && !Array.isArray(params[key])) {
|
||||
if (params[key] && typeof params[key] === "object" && !Array.isArray(params[key])) {
|
||||
params[key] = JSON.stringify(params[key]);
|
||||
}
|
||||
}
|
||||
|
||||
const payload = {
|
||||
name: modelName,
|
||||
params: params
|
||||
params: params,
|
||||
};
|
||||
|
||||
subscribeToData(payload, callback);
|
||||
@@ -1120,7 +1322,10 @@ export default defineNuxtPlugin(() => {
|
||||
try {
|
||||
var rs;
|
||||
let found = findapi(name);
|
||||
if (!Array.isArray(id)) rs = await $fetch(`${path}${found.url_detail}${id}`, { method: "delete" });
|
||||
if (!Array.isArray(id))
|
||||
rs = await $fetch(`${path}${found.url_detail}${id}`, {
|
||||
method: "delete",
|
||||
});
|
||||
else {
|
||||
let params = { action: "delete" };
|
||||
rs = await $fetch(`${path}import-data/${found.url.substring(5, found.url.length - 1)}/`, id, {
|
||||
@@ -1183,12 +1388,12 @@ export default defineNuxtPlugin(() => {
|
||||
};
|
||||
|
||||
const buildFileUrl = (file) => {
|
||||
if (!file || typeof file !== 'string') {
|
||||
console.error(`Invalid file__file: ${file}`)
|
||||
return;
|
||||
if (!file || typeof file !== "string") {
|
||||
console.error(`Invalid file__file: ${file}`);
|
||||
return;
|
||||
}
|
||||
return `${getpath()}static/files/${encodeURIComponent(file)}`;
|
||||
}
|
||||
};
|
||||
|
||||
const generateDocument = async (params) => {
|
||||
const apiBaseUrl = path;
|
||||
@@ -1215,7 +1420,10 @@ export default defineNuxtPlugin(() => {
|
||||
return { success: true, pdfUrl: pdfUrl, data: response };
|
||||
} else {
|
||||
console.error("generateDocument: Định dạng phản hồi API không hợp lệ.", response);
|
||||
return { success: false, error: "Định dạng phản hồi API không hợp lệ." };
|
||||
return {
|
||||
success: false,
|
||||
error: "Định dạng phản hồi API không hợp lệ.",
|
||||
};
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Lỗi khi tạo tài liệu:", error);
|
||||
@@ -1239,14 +1447,17 @@ export default defineNuxtPlugin(() => {
|
||||
return { success: true, data: response };
|
||||
} else {
|
||||
console.error("Định dạng phản hồi API không hợp lệ.", response);
|
||||
return { success: false, error: "Định dạng phản hồi API không hợp lệ." };
|
||||
return {
|
||||
success: false,
|
||||
error: "Định dạng phản hồi API không hợp lệ.",
|
||||
};
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Lỗi khi tạo accountEntry:", error);
|
||||
return { success: false, error: error.data?.message || error.message };
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {'edit' | 'view'} right
|
||||
* @param {{ code?: string, category?: string }} options
|
||||
@@ -1255,36 +1466,38 @@ export default defineNuxtPlugin(() => {
|
||||
* - If not passed, returns edit rights for current tab & subtab
|
||||
* @returns {boolean}
|
||||
*/
|
||||
const getEditRights = (right = 'edit', { code, category } = {}) => {
|
||||
if (!['edit', 'view'].includes(right)) throw new Error(`right ${right} is not one of ['edit', 'view']`);
|
||||
|
||||
const getEditRights = (right = "edit", { code, category } = {}) => {
|
||||
if (!["edit", "view"].includes(right)) throw new Error(`right ${right} is not one of ['edit', 'view']`);
|
||||
|
||||
const getRight = (rightObj) => {
|
||||
return right === 'edit' ? rightObj && rightObj.is_edit : Boolean(rightObj);
|
||||
}
|
||||
return right === "edit" ? rightObj && rightObj.is_edit : Boolean(rightObj);
|
||||
};
|
||||
|
||||
if (store.rights.length === 0) return true; // full rights
|
||||
|
||||
if (code && category) {
|
||||
// if passed, must pass both
|
||||
const foundRight = store.rights.find(({ setting__category, setting__code }) => setting__category === category && setting__code === code);
|
||||
const foundRight = store.rights.find(
|
||||
({ setting__category, setting__code }) => setting__category === category && setting__code === code,
|
||||
);
|
||||
return getRight(foundRight);
|
||||
} else {
|
||||
const { tab, subtab } = store.tabinfo;
|
||||
let isTabEdit;
|
||||
let isSubTabEdit;
|
||||
|
||||
const tabRight = store.rights.find(rights => rights.setting === tab.id);
|
||||
const tabRight = store.rights.find((rights) => rights.setting === tab.id);
|
||||
isTabEdit = getRight(tabRight);
|
||||
|
||||
if (!subtab) isSubTabEdit = false;
|
||||
else {
|
||||
const subTabRight = store.rights.find(rights => rights.setting === subtab.id);
|
||||
const subTabRight = store.rights.find((rights) => rights.setting === subtab.id);
|
||||
isSubTabEdit = getRight(subTabRight);
|
||||
}
|
||||
|
||||
return isTabEdit || isSubTabEdit;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// --- WebSocket Integration ---
|
||||
let socket = null;
|
||||
@@ -1298,7 +1511,7 @@ export default defineNuxtPlugin(() => {
|
||||
// Use wss for https, ws for http
|
||||
const wsProtocol = window.location.protocol === "https:" ? "wss:" : "wss:";
|
||||
// Construct base URL without http/https protocol
|
||||
const baseUrl = path.replace(/^https?:\/\//, '');
|
||||
const baseUrl = path.replace(/^https?:\/\//, "");
|
||||
const wsUrl = `${wsProtocol}//${baseUrl}ws/data/`;
|
||||
|
||||
socket = new WebSocket(wsUrl);
|
||||
@@ -1311,14 +1524,14 @@ export default defineNuxtPlugin(() => {
|
||||
const response = JSON.parse(event.data);
|
||||
|
||||
// Handle initial subscription responses with specific callbacks
|
||||
if (response.type === 'subscription_response' && response.request_id && requests[response.request_id]) {
|
||||
if (response.type === "subscription_response" && response.request_id && requests[response.request_id]) {
|
||||
const callback = requests[response.request_id];
|
||||
callback(response.data);
|
||||
delete requests[response.request_id]; // Clean up callback after use
|
||||
} else {
|
||||
// For all other messages (like realtime_update), dispatch a global event
|
||||
// This decouples the plugin from the store logic
|
||||
window.dispatchEvent(new CustomEvent('ws_message', { detail: response }));
|
||||
window.dispatchEvent(new CustomEvent("ws_message", { detail: response }));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1351,11 +1564,11 @@ export default defineNuxtPlugin(() => {
|
||||
const request = {
|
||||
action: "subscribe",
|
||||
request_id: requestId,
|
||||
payload: payload
|
||||
payload: payload,
|
||||
};
|
||||
|
||||
socket.send(JSON.stringify(request));
|
||||
console.log('[WebSocket] Sent subscription request:', request);
|
||||
console.log("[WebSocket] Sent subscription request:", request);
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
@@ -1,8 +1,24 @@
|
||||
export default defineNuxtPlugin(async (nuxtApp) => {
|
||||
const { $getapi, $readyapi } = useNuxtApp()
|
||||
let connlist = $readyapi(['datatype', 'filterchoice', 'colorchoice', 'textalign', 'placement', 'colorscheme',
|
||||
'filtertype', 'sorttype', 'tablesetting', 'settingchoice', 'sharechoice', 'menuchoice', 'settingtype', 'settingclass',
|
||||
'sex', 'legaltype', 'cart'])
|
||||
let filter = connlist.filter(v=>!v.ready)
|
||||
if(filter.length>0) await $getapi(filter)
|
||||
})
|
||||
const { $getapi, $readyapi } = useNuxtApp();
|
||||
let connlist = $readyapi([
|
||||
"datatype",
|
||||
"filterchoice",
|
||||
"colorchoice",
|
||||
"textalign",
|
||||
"placement",
|
||||
"colorscheme",
|
||||
"filtertype",
|
||||
"sorttype",
|
||||
"tablesetting",
|
||||
"settingchoice",
|
||||
"sharechoice",
|
||||
"menuchoice",
|
||||
"settingtype",
|
||||
"settingclass",
|
||||
"sex",
|
||||
"legaltype",
|
||||
"cart",
|
||||
]);
|
||||
let filter = connlist.filter((v) => !v.ready);
|
||||
if (filter.length > 0) await $getapi(filter);
|
||||
});
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
import { defineNuxtPlugin } from "#app";
|
||||
import Dashboard from '@/components/dashboard/Dashboard.vue';
|
||||
import Orders from '@/components/orders/Orders.vue';
|
||||
import Inventory from '@/components/inventory/Inventory.vue';
|
||||
import Rights from '@/components/rights/Rights.vue';
|
||||
import POS from '@/components/pos/POS.vue';
|
||||
import Receipts from '@/components/receipts/Receipts.vue';
|
||||
import Imports from '@/components/imports/Imports.vue';
|
||||
import Exports from '@/components/exports/Exports.vue';
|
||||
import InventoryTransfer from '@/components/inventory-transfer/InventoryTransfer.vue';
|
||||
import InventoryCount from '@/components/inventory-count/InventoryCount.vue';
|
||||
import CashBook from '@/components/cash-book/CashBook.vue';
|
||||
import NCC from '@/components/report/NCC.vue';
|
||||
import Customers from '@/components/report/Customers.vue';
|
||||
import Goods from '@/components/report/Goods.vue';
|
||||
import ReportCashBook from '@/components/report/CashBook.vue';
|
||||
import Finance from '@/components/report/Finance.vue';
|
||||
import Dashboard from "@/components/dashboard/Dashboard.vue";
|
||||
import Orders from "@/components/orders/Orders.vue";
|
||||
import Inventory from "@/components/inventory/Inventory.vue";
|
||||
import Rights from "@/components/rights/Rights.vue";
|
||||
import POS from "@/components/pos/POS.vue";
|
||||
import Receipts from "@/components/receipts/Receipts.vue";
|
||||
import Imports from "@/components/imports/Imports.vue";
|
||||
import Exports from "@/components/exports/Exports.vue";
|
||||
import InventoryTransfer from "@/components/inventory-transfer/InventoryTransfer.vue";
|
||||
import InventoryCount from "@/components/inventory-count/InventoryCount.vue";
|
||||
import CashBook from "@/components/cash-book/CashBook.vue";
|
||||
import NCC from "@/components/report/NCC.vue";
|
||||
import Customers from "@/components/report/Customers.vue";
|
||||
import Goods from "@/components/report/Goods.vue";
|
||||
import ReportCashBook from "@/components/report/CashBook.vue";
|
||||
import Finance from "@/components/report/Finance.vue";
|
||||
import Notebox from "~/components/common/Notebox.vue";
|
||||
import ProductCountbox from "~/components/common/ProductCountbox.vue";
|
||||
import SvgIcon from "~/components/SvgIcon.vue";
|
||||
@@ -30,7 +30,7 @@ import ChipImage from "~/components/media/ChipImage.vue";
|
||||
import Avatarbox from "~/components/common/Avatarbox.vue";
|
||||
import Email from "~/components/marketing/email/Email.vue";
|
||||
import ViewList from "~/components/common/ViewList.vue";
|
||||
import InternalEntry from "~/components/modal/InternalEntry.vue"
|
||||
import InternalEntry from "~/components/modal/InternalEntry.vue";
|
||||
|
||||
import Configuration from "~/components/maintab/Configuration.vue";
|
||||
import DebtView from "~/components/accounting/DebtView.vue";
|
||||
@@ -66,18 +66,18 @@ import CalculationView from "~/components/application/CalculationView.vue";
|
||||
import InternalAccount from "~/components/accounting/InternalAccount.vue";
|
||||
import MenuAccount from "~/components/menu/MenuAccount.vue";
|
||||
import PhaseAdvance from "~/components/application/PhaseAdvance.vue";
|
||||
import ImageLayout from '@/components/media/ImageLayout.vue';
|
||||
import ProjectDocuments from '~/components/product/ProjectDocuments.vue';
|
||||
import ProductEdit from '~/components/product/ProductEdit.vue';
|
||||
import ImageLayout from "@/components/media/ImageLayout.vue";
|
||||
import ProjectDocuments from "~/components/product/ProjectDocuments.vue";
|
||||
import ProductEdit from "~/components/product/ProductEdit.vue";
|
||||
|
||||
import Cart from '~/components/product/Cart.vue'
|
||||
import CountdownTimer from '~/components/common/CountdownTimer.vue'
|
||||
import CustomerInfo2 from '~/components/customer/CustomerInfo2.vue'
|
||||
import MenuFile from '~/components/menu/MenuFile.vue'
|
||||
import DebtProduct from '~/components/accounting/DebtProduct.vue'
|
||||
import DebtCustomer from '~/components/accounting/DebtCustomer.vue'
|
||||
import Due from '~/components/debt/Due.vue';
|
||||
import Overdue from '@/components/debt/Overdue.vue';
|
||||
import Cart from "~/components/product/Cart.vue";
|
||||
import CountdownTimer from "~/components/common/CountdownTimer.vue";
|
||||
import CustomerInfo2 from "~/components/customer/CustomerInfo2.vue";
|
||||
import MenuFile from "~/components/menu/MenuFile.vue";
|
||||
import DebtProduct from "~/components/accounting/DebtProduct.vue";
|
||||
import DebtCustomer from "~/components/accounting/DebtCustomer.vue";
|
||||
import Due from "~/components/debt/Due.vue";
|
||||
import Overdue from "@/components/debt/Overdue.vue";
|
||||
|
||||
const components = {
|
||||
DebtView,
|
||||
|
||||
Reference in New Issue
Block a user