changes
This commit is contained in:
@@ -31,7 +31,7 @@ let record = await $getdata("application", {
|
|||||||
first: true,
|
first: true,
|
||||||
});
|
});
|
||||||
async function save() {
|
async function save() {
|
||||||
await $patchapi("application", record);
|
await $patchapi("application", { data: record });
|
||||||
record = await $getdata("application", {
|
record = await $getdata("application", {
|
||||||
filter: { id: props.row.id },
|
filter: { id: props.row.id },
|
||||||
first: true,
|
first: true,
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ export default {
|
|||||||
data = this.$copy(this.current);
|
data = this.$copy(this.current);
|
||||||
data.detail = this.detail;
|
data.detail = this.detail;
|
||||||
}
|
}
|
||||||
let rs = data.id ? await this.$patchapi(this.api, data) : await this.$insertapi(this.api, { data });
|
let rs = data.id ? await this.$patchapi(this.api, { data }) : await this.$insertapi(this.api, { data });
|
||||||
if (!rs) return;
|
if (!rs) return;
|
||||||
this.detail = undefined;
|
this.detail = undefined;
|
||||||
if (this.current) {
|
if (this.current) {
|
||||||
|
|||||||
@@ -270,7 +270,7 @@ async function update() {
|
|||||||
record.value.updater = store.login.id;
|
record.value.updater = store.login.id;
|
||||||
record.update_time = new Date();
|
record.update_time = new Date();
|
||||||
let rs = record.value.id
|
let rs = record.value.id
|
||||||
? await $patchapi("company", record.value)
|
? await $patchapi("company", { data: record.value })
|
||||||
: await $insertapi("company", { data: record.value });
|
: await $insertapi("company", { data: record.value });
|
||||||
if (rs === "error") return;
|
if (rs === "error") return;
|
||||||
if (!record.value.id) $snackbar(`Khách hàng đã được khởi tạo với mã <b>${rs.code}</b>`, "Success");
|
if (!record.value.id) $snackbar(`Khách hàng đã được khởi tạo với mã <b>${rs.code}</b>`, "Success");
|
||||||
|
|||||||
@@ -413,7 +413,7 @@ async function update() {
|
|||||||
|
|
||||||
let res = isNewCustomer.value
|
let res = isNewCustomer.value
|
||||||
? await $insertapi("customer", { data: customerData, notify: false })
|
? await $insertapi("customer", { data: customerData, notify: false })
|
||||||
: await $patchapi("customer", customerData, undefined, false);
|
: await $patchapi("customer", { data: customerData, notify: false });
|
||||||
if (!res || res === "error") return;
|
if (!res || res === "error") return;
|
||||||
|
|
||||||
const customerId = res.id;
|
const customerId = res.id;
|
||||||
@@ -423,14 +423,20 @@ async function update() {
|
|||||||
let indPayload = $resetNull({ ...individualData.value });
|
let indPayload = $resetNull({ ...individualData.value });
|
||||||
indPayload.customer = customerId;
|
indPayload.customer = customerId;
|
||||||
if (individualData.value.id)
|
if (individualData.value.id)
|
||||||
await $patchapi("individual", { ...indPayload, id: individualData.value.id }, undefined, false);
|
await $patchapi("individual", {
|
||||||
|
data: { ...indPayload, id: individualData.value.id },
|
||||||
|
notify: false,
|
||||||
|
});
|
||||||
else await $insertapi("individual", { data: indPayload, notify: false });
|
else await $insertapi("individual", { data: indPayload, notify: false });
|
||||||
} else if (isOrganization.value) {
|
} else if (isOrganization.value) {
|
||||||
let orgPayload = $resetNull({ ...organizationData.value });
|
let orgPayload = $resetNull({ ...organizationData.value });
|
||||||
orgPayload.customer = customerId;
|
orgPayload.customer = customerId;
|
||||||
let orgRes;
|
let orgRes;
|
||||||
if (organizationData.value.id) {
|
if (organizationData.value.id) {
|
||||||
orgRes = await $patchapi("organization", { ...orgPayload, id: organizationData.value.id }, undefined, false);
|
orgRes = await $patchapi("organization", {
|
||||||
|
data: { ...orgPayload, id: organizationData.value.id },
|
||||||
|
notify: false,
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
orgRes = await $insertapi("organization", { data: orgPayload, notify: false });
|
orgRes = await $insertapi("organization", { data: orgPayload, notify: false });
|
||||||
}
|
}
|
||||||
@@ -459,7 +465,7 @@ async function update() {
|
|||||||
const payload = { ...lp, ...commonPayload };
|
const payload = { ...lp, ...commonPayload };
|
||||||
|
|
||||||
if (!match) {
|
if (!match) {
|
||||||
$patchapi(apiName, payload);
|
$patchapi(apiName, { data: payload });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ async function saveSetting() {
|
|||||||
detail,
|
detail,
|
||||||
update_time: new Date(),
|
update_time: new Date(),
|
||||||
};
|
};
|
||||||
result = await $patchapi("usersetting", updatedSetting);
|
result = await $patchapi("usersetting", { data: updatedSetting });
|
||||||
}
|
}
|
||||||
isLoading.value = false;
|
isLoading.value = false;
|
||||||
if (radioSave.value === "new") {
|
if (radioSave.value === "new") {
|
||||||
|
|||||||
@@ -31,12 +31,11 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
async created() {
|
async created() {
|
||||||
if (!this.approvalcode && this.$store.state.login.approval_code)
|
if (!this.approvalcode && this.$store.login.approval_code) this.approvalcode = this.$store.login.approval_code;
|
||||||
this.approvalcode = this.$store.state.login.approval_code;
|
|
||||||
if (!this.approvalcode) {
|
if (!this.approvalcode) {
|
||||||
const user = await this.$getdata("user", {
|
const user = await this.$getdata("user", {
|
||||||
first: true,
|
first: true,
|
||||||
filter: { id: this.$store.state.login.id },
|
filter: { id: this.$store.login.id },
|
||||||
});
|
});
|
||||||
this.approvalcode = user.approval_code;
|
this.approvalcode = user.approval_code;
|
||||||
}
|
}
|
||||||
@@ -47,7 +46,7 @@ export default {
|
|||||||
computed: {
|
computed: {
|
||||||
approvalcode: {
|
approvalcode: {
|
||||||
get() {
|
get() {
|
||||||
return this.$store.state["approvalcode"];
|
return this.$store.approvalcode;
|
||||||
},
|
},
|
||||||
set(val) {
|
set(val) {
|
||||||
this.$store.commit("updateStore", { name: "approvalcode", data: val });
|
this.$store.commit("updateStore", { name: "approvalcode", data: val });
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ export default {
|
|||||||
if (this.setdeleted) {
|
if (this.setdeleted) {
|
||||||
let record = await this.$getdata(name, { first: true, filter: { id } });
|
let record = await this.$getdata(name, { first: true, filter: { id } });
|
||||||
record.deleted = 1;
|
record.deleted = 1;
|
||||||
result = await this.$patchapi(name, record);
|
result = await this.$patchapi(name, { data: record });
|
||||||
} else result = await this.$deleteapi(name, id);
|
} else result = await this.$deleteapi(name, id);
|
||||||
if (result === "error") return this.$dialog("Đã xảy ra lỗi, xóa dữ liệu thất bại", "Lỗi", "Error");
|
if (result === "error") return this.$dialog("Đã xảy ra lỗi, xóa dữ liệu thất bại", "Lỗi", "Error");
|
||||||
this.$snackbar("Dữ liệu đã được xoá khỏi hệ thống", "Success");
|
this.$snackbar("Dữ liệu đã được xoá khỏi hệ thống", "Success");
|
||||||
|
|||||||
@@ -74,8 +74,10 @@ async function submit() {
|
|||||||
isPending.value = true;
|
isPending.value = true;
|
||||||
const res = props.variantId
|
const res = props.variantId
|
||||||
? await $patchapi("Product", {
|
? await $patchapi("Product", {
|
||||||
id: productVariant.value.product,
|
data: {
|
||||||
...body.value,
|
id: productVariant.value.product,
|
||||||
|
...body.value,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
: await $insertapi("Product", { data: body.value });
|
: await $insertapi("Product", { data: body.value });
|
||||||
if (res !== "error") {
|
if (res !== "error") {
|
||||||
|
|||||||
@@ -98,8 +98,10 @@ async function submit() {
|
|||||||
const trimmedBody = omitBy(body.value, $empty);
|
const trimmedBody = omitBy(body.value, $empty);
|
||||||
const res = props.variantId
|
const res = props.variantId
|
||||||
? await $patchapi("Product_Variant", {
|
? await $patchapi("Product_Variant", {
|
||||||
id: props.variantId,
|
data: {
|
||||||
...trimmedBody,
|
id: props.variantId,
|
||||||
|
...trimmedBody,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
: await $insertapi("Product_Variant", { data: trimmedBody });
|
: await $insertapi("Product_Variant", { data: trimmedBody });
|
||||||
if (res !== "error") {
|
if (res !== "error") {
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ const handleSave = async () => {
|
|||||||
...props.data,
|
...props.data,
|
||||||
name: templateName.value,
|
name: templateName.value,
|
||||||
};
|
};
|
||||||
response = await $patchapi("Email_Template", patchData);
|
response = await $patchapi("Email_Template", { data: patchData });
|
||||||
} else {
|
} else {
|
||||||
const insertData = {
|
const insertData = {
|
||||||
...props.data,
|
...props.data,
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async save() {
|
async save() {
|
||||||
let rs = await this.$patchapi("file", this.record);
|
let rs = await this.$patchapi("file", { data: this.record });
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ export default {
|
|||||||
computed: {
|
computed: {
|
||||||
pagedata: {
|
pagedata: {
|
||||||
get() {
|
get() {
|
||||||
return this.$store.state[this.pagename1];
|
return this.$store[this.pagename1];
|
||||||
},
|
},
|
||||||
set(val) {
|
set(val) {
|
||||||
this.$store.commit("updateStore", { name: this.pagename1, data: val });
|
this.$store.commit("updateStore", { name: this.pagename1, data: val });
|
||||||
|
|||||||
@@ -33,10 +33,12 @@ function editImage(image) {
|
|||||||
async function saveEditImage() {
|
async function saveEditImage() {
|
||||||
try {
|
try {
|
||||||
await $patchapi("file", {
|
await $patchapi("file", {
|
||||||
id: editingImage.value.file,
|
data: {
|
||||||
name: editingImageName.value,
|
id: editingImage.value.file,
|
||||||
caption: editingImageCaption.value?.trim() || null,
|
name: editingImageName.value,
|
||||||
hashtag: editingImageHashtag.value?.trim() || null,
|
caption: editingImageCaption.value?.trim() || null,
|
||||||
|
hashtag: editingImageHashtag.value?.trim() || null,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
props.loadImages();
|
props.loadImages();
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ export default {
|
|||||||
},
|
},
|
||||||
async saveData() {
|
async saveData() {
|
||||||
if (!this.row) return this.insertData();
|
if (!this.row) return this.insertData();
|
||||||
await this.$patchapi("importsetting", this.current, undefined, this.pagename);
|
await this.$patchapi("importsetting", { data: this.current, notify: this.pagename });
|
||||||
},
|
},
|
||||||
updateFromModel() {
|
updateFromModel() {
|
||||||
let filter = this.$filter(this.pagedata2.data, {
|
let filter = this.$filter(this.pagedata2.data, {
|
||||||
|
|||||||
@@ -360,7 +360,7 @@ async function update() {
|
|||||||
record.value.updater = store.login.id;
|
record.value.updater = store.login.id;
|
||||||
record.value.updater_time = new Date();
|
record.value.updater_time = new Date();
|
||||||
let rs = record.value.id
|
let rs = record.value.id
|
||||||
? await $patchapi("people", record.value)
|
? await $patchapi("people", { data: record.value })
|
||||||
: await $insertapi("people", { data: record.value, notify: false });
|
: await $insertapi("people", { data: record.value, notify: false });
|
||||||
if (rs === "error") return;
|
if (rs === "error") return;
|
||||||
if (!record.value.id) $snackbar(`Người liên quan đã được khởi tạo với mã <b>${rs.code}</b>`, "Success");
|
if (!record.value.id) $snackbar(`Người liên quan đã được khởi tạo với mã <b>${rs.code}</b>`, "Success");
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ async function submitAddress() {
|
|||||||
customer: props.customerId,
|
customer: props.customerId,
|
||||||
};
|
};
|
||||||
const res = props.address
|
const res = props.address
|
||||||
? await $patchapi("Customer_Address", payload)
|
? await $patchapi("Customer_Address", { data: payload })
|
||||||
: await $insertapi("Customer_Address", { data: payload });
|
: await $insertapi("Customer_Address", { data: payload });
|
||||||
isLoading.value = false;
|
isLoading.value = false;
|
||||||
emit("modalevent", { name: "submit" });
|
emit("modalevent", { name: "submit" });
|
||||||
|
|||||||
@@ -120,7 +120,12 @@ export default function usePlaceOrder({ onSuccess }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// update invoice.payment_status from PENDING to PAID
|
// update invoice.payment_status from PENDING to PAID
|
||||||
await $patchapi("Invoice", { id: invoiceId, payment_status: paidPaymentStatus.value.id });
|
await $patchapi("Invoice", {
|
||||||
|
data: {
|
||||||
|
id: invoiceId,
|
||||||
|
payment_status: paidPaymentStatus.value.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
await onOrderSuccess();
|
await onOrderSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,8 +211,10 @@ export default function usePlaceOrder({ onSuccess }) {
|
|||||||
activeCartItems.value.map((c) => c.id),
|
activeCartItems.value.map((c) => c.id),
|
||||||
),
|
),
|
||||||
$patchapi("Cart", {
|
$patchapi("Cart", {
|
||||||
id: activeCartItems.value[0].cart,
|
data: {
|
||||||
customer: null,
|
id: activeCartItems.value[0].cart,
|
||||||
|
customer: null,
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
posStore.getCarts();
|
posStore.getCarts();
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ async function changePassword() {
|
|||||||
|
|
||||||
let rs0 = await proxy.$insertapi("gethash", { data: { text: password.value }, notify: false });
|
let rs0 = await proxy.$insertapi("gethash", { data: { text: password.value }, notify: false });
|
||||||
user.password = rs0.rows[0];
|
user.password = rs0.rows[0];
|
||||||
let rs = await proxy.$patchapi("user", user, undefined, false);
|
let rs = await proxy.$patchapi("user", { data: user, notify: false });
|
||||||
|
|
||||||
if (rs !== "error") {
|
if (rs !== "error") {
|
||||||
currpass.value = undefined;
|
currpass.value = undefined;
|
||||||
|
|||||||
@@ -51,9 +51,9 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
async confirm() {
|
async confirm() {
|
||||||
if (this.checkError()) return this.$snackbar("Mã phê duyệt gồm 4 số từ 0-9");
|
if (this.checkError()) return this.$snackbar("Mã phê duyệt gồm 4 số từ 0-9");
|
||||||
let user = await this.$getdata("user", { first: true, filter: { id: this.$store.state.login.id } });
|
let user = await this.$getdata("user", { first: true, filter: { id: this.$store.login.id } });
|
||||||
user.approval_code = this.code;
|
user.approval_code = this.code;
|
||||||
await this.$patchapi("user", user);
|
await this.$patchapi("user", { data: user });
|
||||||
},
|
},
|
||||||
checkError() {
|
checkError() {
|
||||||
if (Object.keys(this.data).length < 4) return true;
|
if (Object.keys(this.data).length < 4) return true;
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ export default {
|
|||||||
});
|
});
|
||||||
let rs = await this.$insertapi("gethash", { data: { text: this.password } });
|
let rs = await this.$insertapi("gethash", { data: { text: this.password } });
|
||||||
user.password = rs.rows[0];
|
user.password = rs.rows[0];
|
||||||
let rs1 = await this.$patchapi("user", user);
|
let rs1 = await this.$patchapi("user", { data: user });
|
||||||
if (rs1 !== "error") this.$emit("close");
|
if (rs1 !== "error") this.$emit("close");
|
||||||
else {
|
else {
|
||||||
this.$snackbar("Có lỗi xảy ra. Hãy thử lại một lần nữa", "Error");
|
this.$snackbar("Có lỗi xảy ra. Hãy thử lại một lần nữa", "Error");
|
||||||
|
|||||||
@@ -132,10 +132,10 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|||||||
/**
|
/**
|
||||||
* @param {ApiName} name
|
* @param {ApiName} name
|
||||||
*/
|
*/
|
||||||
const patchapi = async function (name, data, values, notify) {
|
const patchapi = async function (name, { data, values, notify = true } = {}) {
|
||||||
try {
|
try {
|
||||||
const api = findapi(name);
|
const api = findapi(name);
|
||||||
const curpath = api.path ? paths.find((x) => x.name === api.path).url : path;
|
const curpath = getpath(api.path);
|
||||||
const updateUrl = api.url_detail || api.url;
|
const updateUrl = api.url_detail || api.url;
|
||||||
|
|
||||||
const rs = await $fetch(`${curpath}${updateUrl}${data.id}/`, {
|
const rs = await $fetch(`${curpath}${updateUrl}${data.id}/`, {
|
||||||
@@ -312,7 +312,7 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const updaterow = async function (name, data, values, pagename, notify) {
|
const updaterow = async function (name, data, values, pagename, notify) {
|
||||||
let result = await patchapi(name, data, values, notify);
|
let result = await patchapi(name, { data, values, notify });
|
||||||
if (result === "error" || !pagename || !store[pagename]) return result;
|
if (result === "error" || !pagename || !store[pagename]) return result;
|
||||||
let copy = cloneDeep(store[pagename]);
|
let copy = cloneDeep(store[pagename]);
|
||||||
copy.update = { refresh: true };
|
copy.update = { refresh: true };
|
||||||
|
|||||||
@@ -37,8 +37,10 @@ export const usePosStore = defineStore("pos", () => {
|
|||||||
async function changeCustomer(cusId) {
|
async function changeCustomer(cusId) {
|
||||||
isChangingCus.value = true;
|
isChangingCus.value = true;
|
||||||
const updatedCart = await $patchapi("Cart", {
|
const updatedCart = await $patchapi("Cart", {
|
||||||
id: activeCartId.value,
|
data: {
|
||||||
customer: cusId,
|
id: activeCartId.value,
|
||||||
|
customer: cusId,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
await getCarts();
|
await getCarts();
|
||||||
isChangingCus.value = false;
|
isChangingCus.value = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user