fix
This commit is contained in:
parent
7fde4188f0
commit
368643b7f5
|
|
@ -5,11 +5,12 @@ import { FMLocal, FieldLocal } from "../../typings";
|
|||
import { PropTypeInput } from "./TypeInput";
|
||||
import * as XLSX from "xlsx";
|
||||
|
||||
|
||||
export const FieldUpload: FC<{
|
||||
field: FieldLocal;
|
||||
fm: FMLocal;
|
||||
prop: PropTypeInput;
|
||||
on_change: (e: any) => void | Promise<void>
|
||||
on_change: (e: any) => void | Promise<void>;
|
||||
}> = ({ field, fm, prop, on_change }) => {
|
||||
let type_field = prop.sub_type;
|
||||
let value: any = fm.data[field.name];
|
||||
|
|
@ -21,7 +22,8 @@ export const FieldUpload: FC<{
|
|||
drop: false as boolean,
|
||||
});
|
||||
let display: any = null;
|
||||
const disabled = typeof field.disabled === "function" ? field.disabled() : field.disabled;
|
||||
const disabled =
|
||||
typeof field.disabled === "function" ? field.disabled() : field.disabled;
|
||||
return (
|
||||
<div className="c-flex-grow c-flex-row c-flex c-w-full c-h-full">
|
||||
<div
|
||||
|
|
@ -79,25 +81,30 @@ export const FieldUpload: FC<{
|
|||
|
||||
reader.onload = (e: any) => {
|
||||
const binaryStr = e.target.result;
|
||||
const workbook = XLSX.read(binaryStr, { type: 'binary' });
|
||||
const workbook = XLSX.read(binaryStr, { type: "binary" });
|
||||
|
||||
const worksheet = workbook.Sheets[workbook.SheetNames[0]];
|
||||
const jsonData = XLSX.utils.sheet_to_json(worksheet);
|
||||
if (typeof on_change === "function") {
|
||||
const res = on_change({ value: jsonData });
|
||||
}
|
||||
}
|
||||
};
|
||||
reader.readAsBinaryString(file);
|
||||
} else {
|
||||
const formData = new FormData();
|
||||
formData.append("file", file);
|
||||
const response = await fetch(
|
||||
"https://prasi.avolut.com/_proxy/https%3A%2F%2Feam.avolut.com%2F_upload",
|
||||
{
|
||||
|
||||
let url = siteurl("/_upload");
|
||||
if (location.hostname === 'prasi.avolut.com' || location.host === 'localhost:4550') {
|
||||
const newurl = new URL(location.href);
|
||||
newurl.pathname = `/_proxy/https://julong-dev.avolut.com/_upload`;
|
||||
url = newurl.toString();
|
||||
}
|
||||
|
||||
const response = await fetch(url, {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
const contentType: any = response.headers.get("content-type");
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ const parse = parser.exportAsFunctionAny("en-US");
|
|||
export const loadSession = (url_login?: string) => {
|
||||
if (!isEditor) {
|
||||
let id_site = "";
|
||||
if (location.hostname === "prasi.avolut.com") {
|
||||
if (location.hostname === "prasi.avolut.com" || location.host === "localhost:4550") {
|
||||
const parts = location.pathname.split("/");
|
||||
id_site = parts[2];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,13 +14,18 @@ export const logout = (url_login?: string) => {
|
|||
}
|
||||
|
||||
let id_site = "";
|
||||
if (location.hostname === "prasi.avolut.com") {
|
||||
if (
|
||||
location.hostname === "prasi.avolut.com" ||
|
||||
location.host === "localhost:4550"
|
||||
) {
|
||||
const parts = location.pathname.split("/");
|
||||
id_site = parts[2];
|
||||
}
|
||||
if (localStorage.getItem("user" + id_site)) {
|
||||
localStorage.removeItem("user" + id_site);
|
||||
}
|
||||
if (url_login !== getPathname())
|
||||
location.href = `${getBasename()}${url_login}`;
|
||||
if (url_login !== getPathname()) {
|
||||
console.log(url_login, getPathname());
|
||||
// location.href = `${getBasename()}${url_login}`;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -21,7 +21,10 @@ export const registerSession = (session: RG) => {
|
|||
};
|
||||
|
||||
let id_site = "";
|
||||
if (location.hostname === "prasi.avolut.com") {
|
||||
if (
|
||||
location.hostname === "prasi.avolut.com" ||
|
||||
location.host === "localhost:4550"
|
||||
) {
|
||||
const parts = location.pathname.split("/");
|
||||
id_site = parts[2];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
export const getPathname = (url?: string) => {
|
||||
if (["prasi.avolut.com"].includes(location.hostname)) {
|
||||
if (
|
||||
["prasi.avolut.com"].includes(location.hostname) ||
|
||||
location.host === "localhost:4550"
|
||||
) {
|
||||
if (
|
||||
location.pathname.startsWith("/vi") ||
|
||||
location.pathname.startsWith("/prod") ||
|
||||
|
|
|
|||
Loading…
Reference in New Issue