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