changes
This commit is contained in:
@@ -4,8 +4,13 @@ export default defineNuxtPlugin(() => {
|
||||
|
||||
//==========Find & filter=================
|
||||
const find = function (arr, obj, attr) {
|
||||
if (typeof arr === "object" && !Array.isArray(arr)) {
|
||||
arr = Object.values(arr);
|
||||
if (!Array.isArray(arr)) {
|
||||
if (typeof arr === "object") {
|
||||
arr = Object.values(arr);
|
||||
} else {
|
||||
console.error(`arr "${arr}" is not an array`);
|
||||
return;
|
||||
}
|
||||
}
|
||||
const keys = Object.keys(obj);
|
||||
let found = arr.find((v) => {
|
||||
|
||||
@@ -570,7 +570,10 @@ export default defineNuxtPlugin((nuxtApp) => {
|
||||
commit: "product",
|
||||
url: "data/Product/",
|
||||
url_detail: "data-detail/Product/",
|
||||
params: {},
|
||||
params: {
|
||||
values:
|
||||
"id,code,name,manufacturer,manufacturer__name,os,os__name,battery,battery__code,screen,cpu,cpu__name,gpu,gpu__name,camera_system,camera_system__code,sim,sim__code,network_technology,network_technology__name,charging_technology,charging_technology__code,external_storage,external_storage__max_capacity,ip_rating,ip_rating__code,design,create_time,update_time",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Product_Variant",
|
||||
@@ -1188,7 +1191,7 @@ export default defineNuxtPlugin((nuxtApp) => {
|
||||
// insert data
|
||||
const insertapi = async function (name, data, values, notify) {
|
||||
try {
|
||||
let found = findapi(name);
|
||||
const found = findapi(name);
|
||||
const curpath = found.path ? paths.find((x) => x.name === found.path).url : path;
|
||||
let rs;
|
||||
if (!Array.isArray(data)) {
|
||||
@@ -1464,13 +1467,13 @@ export default defineNuxtPlugin((nuxtApp) => {
|
||||
});
|
||||
}
|
||||
if (found.commit) {
|
||||
let copy = JSON.parse(JSON.stringify($store[found.commit]));
|
||||
const copy = $copy($store[found.commit]);
|
||||
if (!Array.isArray(id)) {
|
||||
let index = copy.findIndex((v) => v.id === id);
|
||||
const index = copy.findIndex((v) => v.id === id);
|
||||
if (index >= 0) $remove(copy, index);
|
||||
} else {
|
||||
rs.forEach((element) => {
|
||||
let index = copy.findIndex((v) => v.id === element.id);
|
||||
const index = copy.findIndex((v) => v.id === element.id);
|
||||
if (index >= 0) $remove(copy, index);
|
||||
});
|
||||
}
|
||||
@@ -1478,7 +1481,7 @@ export default defineNuxtPlugin((nuxtApp) => {
|
||||
}
|
||||
return id;
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
console.error(err);
|
||||
if (err.response) {
|
||||
let content = `<span>Đã xảy ra lỗi, xóa dữ liệu không thành công</span>`;
|
||||
if (err.response.data)
|
||||
|
||||
@@ -7,6 +7,8 @@ import POS from "@/components/pos/POS.vue";
|
||||
import CreateReceipts from "@/components/receipts/CreateReceipts.vue";
|
||||
import Return from "@/components/receipts/Return.vue";
|
||||
import Imports from "@/components/imports/Imports.vue";
|
||||
import AddProductForm from "@/components/imports/AddProductForm.vue";
|
||||
import DeleteProduct from "@/components/imports/DeleteProduct.vue";
|
||||
import AddOS from "@/components/imports/addons/AddOS.vue";
|
||||
import AddManufacturer from "@/components/imports/addons/AddManufacturer.vue";
|
||||
import AddBattery from "@/components/imports/addons/AddBattery.vue";
|
||||
@@ -168,6 +170,8 @@ const components = {
|
||||
CreateReceipts,
|
||||
Return,
|
||||
Imports,
|
||||
AddProductForm,
|
||||
DeleteProduct,
|
||||
AddOS,
|
||||
AddManufacturer,
|
||||
AddBattery,
|
||||
|
||||
Reference in New Issue
Block a user