From a7c81c5c8515ad89f95467c0465f04a69657051a Mon Sep 17 00:00:00 2001
From: qanglee <545540710@qq.com>
Date: Wed, 7 Aug 2024 16:54:12 +0800
Subject: [PATCH] dev
---
.../admin-antd/src/common/hooks/useActive.tsx | 2 +-
.../components/keepAlive/keepAliveOutlet.tsx | 2 +-
.../src/components/nameInfo/index.tsx | 2 +-
.../marketItemTable/columnsCreater.tsx | 426 +++++++--------
.../posItemsTable/columnsCreater.tsx | 513 +++++++++---------
.../components/posItemsTable/index.tsx | 146 ++---
6 files changed, 545 insertions(+), 546 deletions(-)
diff --git a/frontend/packages/admin-antd/src/common/hooks/useActive.tsx b/frontend/packages/admin-antd/src/common/hooks/useActive.tsx
index d3da5d43..0e6c87df 100644
--- a/frontend/packages/admin-antd/src/common/hooks/useActive.tsx
+++ b/frontend/packages/admin-antd/src/common/hooks/useActive.tsx
@@ -52,7 +52,7 @@ const useActive = (
useEffect(() => {
if (routerHelper.getRouteIdByPath(currentPath.current) == activeKey) {
- debugger;
+ ;
const isFirst = activeFlag.current ?? true;
if (isFirst && onFirstActive) {
onFirstActive?.();
diff --git a/frontend/packages/admin-antd/src/components/keepAlive/keepAliveOutlet.tsx b/frontend/packages/admin-antd/src/components/keepAlive/keepAliveOutlet.tsx
index f0986cb9..fe0503c7 100644
--- a/frontend/packages/admin-antd/src/components/keepAlive/keepAliveOutlet.tsx
+++ b/frontend/packages/admin-antd/src/components/keepAlive/keepAliveOutlet.tsx
@@ -45,7 +45,7 @@ const KeepAliveOutlet = memo(() => {
return item.location?.pathname?.split("/").slice(-1)[0];
});
let allRouteKeys = [...pathArr];
- debugger
+
pathArr.forEach((item) => {
const routeItem= routerHelper.getRoutItemConfigById(
item as ROUTE_ID_KEY
diff --git a/frontend/packages/admin-antd/src/components/nameInfo/index.tsx b/frontend/packages/admin-antd/src/components/nameInfo/index.tsx
index 31f5b54e..3f1e8006 100644
--- a/frontend/packages/admin-antd/src/components/nameInfo/index.tsx
+++ b/frontend/packages/admin-antd/src/components/nameInfo/index.tsx
@@ -4,7 +4,7 @@ const NameInfo = () => {
const { isCollapsedMenu, settingData } = useFlat("appStore");
const antdThemeToken = antdTheme.useToken();
const { projectName, logo } = settingData;
- debugger;
+ ;
return (
{
- const { locationType, exclude } = data;
- let weight = 0;
- weight +=
- {
- P: 1,
- C: 2,
- S: 3,
- N: 4,
- Z: 5,
- A: 6,
- W: 7,
- }[locationType] || 0;
- weight = weight * (exclude ? 1 : 10);
- return weight;
+ const { locationType, exclude } = data;
+ let weight = 0;
+ weight +=
+ {
+ P: 1,
+ C: 2,
+ S: 3,
+ N: 4,
+ Z: 5,
+ A: 6,
+ W: 7,
+ }[locationType] || 0;
+ weight = weight * (exclude ? 1 : 10);
+ return weight;
};
const columnsCreater: ColumnsCreater
= (
- { editingKey, form, save, isEditing, cancel, edit, deleteByKey },
- extra
+ { editingKey, form, save, isEditing, cancel, edit, deleteByKey },
+ extra,
) => {
- const { t } = useTranslation(["market"]);
- const { t: commonT } = useTranslation(["common"]);
- const { setIsDisabledMarketType, setIsEditing } = useFlat([
- "marketStore",
- extra?.branchName,
- ]);
- const isDetail = extra?.branchName == ROUTE_ID.MarketDetailPage;
- let data: MyColumnType[] = [
- {
- title: t("marketPage.locationType"),
- dataIndex: "locationType",
- key: "locationType",
- editable: true,
- align: "center",
- fieldConfig: {
- formOptions: {
- rules: [
- {
- required: true,
- message:
- t`marketPage.placeholder_select` +
- t`marketPage.locationType`,
- },
- ],
- },
- inputAttrConfig: {
- placeholder:
- t`marketPage.placeholder_select` +
- t`marketPage.marketType`,
- maxLength: 60,
- style: {
- width: "140px",
- },
- },
- type: "Select",
- render: LocationTypeField,
- },
- render: (value) => {
- return (
- <>
- {
- (
- {
- P: t`marketPage.AIRPORT`,
- C: t`marketPage.CITY`,
- S: t`marketPage.STATE`,
- N: t`marketPage.COUNTRY`,
- Z: t`marketPage.ATPCO`,
- A: t`marketPage.TC`,
- W: t`marketPage.WORLD`,
- } as any
- )[value]
- }
- >
- );
- },
- },
- {
- title: t("marketPage.location"),
- dataIndex: "locationInfo",
- key: "locationInfo",
- editable: true,
- align: "center",
- fieldConfig: {
- inputAttrConfig: {
- placeholder: t`marketPage.rule_placeholder`,
- },
- formOptions: {
- name: "locationInfo",
- rules: [
- {
- required: true,
- message:
- t`marketPage.placeholder_input` +
- " " +
- t`marketPage.location`,
- },
- ],
- },
- render: LocationField,
- },
- },
- {
- title: t("marketPage.EXCLUDE"),
- dataIndex: "exclude",
- key: "exclude",
- editable: true,
- align: "center",
- render: (value) => {
- return ;
- },
- fieldConfig: {
- type: "Switch",
- formOptions: {
- name: "exclude",
- style: {
- margin: 0,
- },
- valuePropName: "checked",
- initialValue: false,
- },
- },
- },
- {
- title: t("marketPage.weight"),
- dataIndex: "weight",
- key: "weight",
- editable: true,
- align: "center",
- fieldConfig: {
- render: (_, formIns) => {
- const { locationType, exclude } = form.getFieldsValue();
- const weightValue = calcWeight({
- locationType,
- exclude,
- });
- useEffect(() => {
- formIns.setFieldValue("weight", weightValue);
- }, [weightValue]);
+ const { t } = useTranslation(["market"]);
+ const { t: commonT } = useTranslation(["common"]);
+ const { setIsDisabledMarketType, setIsEditing } = useFlat([
+ "marketStore",
+ extra?.branchName,
+ ]);
+ const isDetail = extra?.branchName == ROUTE_ID.MarketDetailPage;
+ let data: MyColumnType[] = [
+ {
+ title: t("marketPage.locationType"),
+ dataIndex: "locationType",
+ key: "locationType",
+ editable: true,
+ align: "center",
+ fieldConfig: {
+ formOptions: {
+ rules: [
+ {
+ required: true,
+ message:
+ t`marketPage.placeholder_select` +
+ t`marketPage.locationType`,
+ },
+ ],
+ },
+ inputAttrConfig: {
+ placeholder:
+ t`marketPage.placeholder_select` +
+ t`marketPage.marketType`,
+ maxLength: 60,
+ style: {
+ width: "140px",
+ },
+ },
+ type: "Select",
+ render: LocationTypeField,
+ },
+ render: (value) => {
+ return (
+ <>
+ {
+ (
+ {
+ P: t`marketPage.AIRPORT`,
+ C: t`marketPage.CITY`,
+ S: t`marketPage.STATE`,
+ N: t`marketPage.COUNTRY`,
+ Z: t`marketPage.ATPCO`,
+ A: t`marketPage.TC`,
+ W: t`marketPage.WORLD`,
+ } as any
+ )[value]
+ }
+ >
+ );
+ },
+ },
+ {
+ title: t("marketPage.location"),
+ dataIndex: "locationInfo",
+ key: "locationInfo",
+ editable: true,
+ align: "center",
+ fieldConfig: {
+ inputAttrConfig: {
+ placeholder: t`marketPage.rule_placeholder`,
+ },
+ formOptions: {
+ name: "locationInfo",
+ rules: [
+ {
+ required: true,
+ message:
+ t`marketPage.placeholder_input` +
+ " " +
+ t`marketPage.location`,
+ },
+ ],
+ },
+ render: LocationField,
+ },
+ },
+ {
+ title: t("marketPage.EXCLUDE"),
+ dataIndex: "exclude",
+ key: "exclude",
+ editable: true,
+ align: "center",
+ render: (value) => {
+ return ;
+ },
+ fieldConfig: {
+ type: "Switch",
+ formOptions: {
+ name: "exclude",
+ style: {
+ margin: 0,
+ },
+ valuePropName: "checked",
+ initialValue: false,
+ },
+ },
+ },
+ {
+ title: t("marketPage.weight"),
+ dataIndex: "weight",
+ key: "weight",
+ editable: true,
+ align: "center",
+ fieldConfig: {
+ render: (_, formIns) => {
+ const { locationType, exclude } = form.getFieldsValue();
+ const weightValue = calcWeight({
+ locationType,
+ exclude,
+ });
+ useEffect(() => {
+ formIns.setFieldValue("weight", weightValue);
+ }, [weightValue]);
- return (
-
- {calcWeight({
- locationType,
- exclude,
- })}
-
- );
- },
- },
- render: (value) => {
- return {value}
;
- },
- },
- ];
- if (isDetail) {
- data.concat({
- title: t("marketPage.operation"),
- dataIndex: "operation",
- align: "center",
- render: (_: any, record) => {
- const editable = isEditing(record);
- return editable ? (
-
- {
- setIsDisabledMarketType(false);
- setIsEditing(false);
- save(record.uid!);
- }}
- style={{ marginRight: 8 }}
- >
-
-
- {
- cancel();
- setIsEditing(false);
- }}
- okText={commonT`blog.Yes`}
- cancelText={commonT`blog.No`}
- >
-
-
-
- ) : (
-
- {
- edit(record);
- setIsEditing(true);
- }}
- style={{ marginRight: 8 }}
- >
- {/* Edit */}
-
-
-
- {
- deleteByKey(record.uid!);
- }}
- okText={commonT`blog.Yes`}
- cancelText={commonT`blog.No`}
- >
- {/* Delete */}
-
-
-
-
- );
- },
- });
- }
- return data;
+ return (
+
+ {calcWeight({
+ locationType,
+ exclude,
+ })}
+
+ );
+ },
+ },
+ render: (value) => {
+ return {value}
;
+ },
+ },
+ ];
+ if (!isDetail) {
+ data = data.concat({
+ title: t("marketPage.operation"),
+ dataIndex: "operation",
+ align: "center",
+ render: (_: any, record) => {
+ const editable = isEditing(record);
+ return editable ? (
+
+ {
+ setIsDisabledMarketType(false);
+ setIsEditing(false);
+ save(record.uid!);
+ }}
+ style={{ marginRight: 8 }}
+ >
+
+
+ {
+ cancel();
+ setIsEditing(false);
+ }}
+ okText={commonT`blog.Yes`}
+ cancelText={commonT`blog.No`}
+ >
+
+
+
+ ) : (
+
+ {
+ edit(record);
+ setIsEditing(true);
+ }}
+ style={{ marginRight: 8 }}
+ >
+ {/* Edit */}
+
+
+
+ {
+ deleteByKey(record.uid!);
+ }}
+ okText={commonT`blog.Yes`}
+ cancelText={commonT`blog.No`}
+ >
+ {/* Delete */}
+
+
+
+
+ );
+ },
+ });
+ }
+ return data;
};
export default columnsCreater;
diff --git a/frontend/packages/admin-antd/src/pages/HomePage/CpdPage/PosPage/components/posItemsTable/columnsCreater.tsx b/frontend/packages/admin-antd/src/pages/HomePage/CpdPage/PosPage/components/posItemsTable/columnsCreater.tsx
index 588699d2..ac272dd0 100644
--- a/frontend/packages/admin-antd/src/pages/HomePage/CpdPage/PosPage/components/posItemsTable/columnsCreater.tsx
+++ b/frontend/packages/admin-antd/src/pages/HomePage/CpdPage/PosPage/components/posItemsTable/columnsCreater.tsx
@@ -10,268 +10,267 @@ import type { PosItem } from "src/service/stores/posStore/model";
import FieldRenderPosInfo from "../customFIelds/posInfo-field";
const calcWeight = (data: {
- posType: string;
- agentOrAirline: string;
- officeOwner: string;
- exclude: boolean;
+ posType: string;
+ agentOrAirline: string;
+ officeOwner: string;
+ exclude: boolean;
}) => {
- const { posType, agentOrAirline, officeOwner, exclude } = data;
- let weight = 0;
- weight += 5 * (!agentOrAirline ? 8 : 1);
- weight += 6 * (!officeOwner || officeOwner == "ALL" ? 6 : 1);
- weight +=
- {
- I: 1,
- T: 2,
- C: 3,
- N: 4,
- W: 48,
- }[posType] || 0;
- weight = weight * (exclude ? 1 : 10);
- console.log(exclude);
- return weight;
+ const { posType, agentOrAirline, officeOwner, exclude } = data;
+ let weight = 0;
+ weight += 5 * (!agentOrAirline ? 8 : 1);
+ weight += 6 * (!officeOwner || officeOwner == "ALL" ? 6 : 1);
+ weight +=
+ {
+ I: 1,
+ T: 2,
+ C: 3,
+ N: 4,
+ W: 48,
+ }[posType] || 0;
+ weight = weight * (exclude ? 1 : 10);
+ console.log(exclude);
+ return weight;
};
const columnsCreater: ColumnsCreater = (
- { editingKey, form, save, isEditing, cancel, edit, deleteByKey },
- extra
+ { editingKey, form, save, isEditing, cancel, edit, deleteByKey },
+ extra,
) => {
- const { t } = useTranslation(["pos"]);
- const { t: commonT } = useTranslation(["common"]);
- const { setIsEditing } = useFlat(["posStore", extra?.branchName]);
- const isDetail = extra?.branchName == ROUTE_ID.RuleDetailPage;
- const data: MyColumnType[] = [
- {
- title: t("posPage.posType"),
- dataIndex: "posType",
- key: "posType",
- editable: true,
- align: "center",
- fieldConfig: {
- options: [
- {
- key: "I",
- value: "I",
- label: t("posPage.IATANUM"),
- },
- {
- key: "T",
- value: "T",
- label: t("posPage.PCC"),
- },
- ],
- inputAttrConfig: {
- placeholder: `${t("posPage.placeholder_select")} ${t(
- "posPage.posType"
- )}`,
- maxLength: 60,
- style: {
- width: "140px",
- },
- },
- type: "Select",
- render: ({ inputAttrConfig, options }, form) => {
- console.log("form.getFieldValue()");
- console.log(form.getFieldValue("posType"));
- const optionArr =
- typeof options == "function" ? options() : options;
- return (
-
-
-
- );
- },
- },
- render: (_, record) => {
- let data = {
- I: t("posPage.IATANUM"),
- T: t("posPage.PCC"),
- };
- return record.posType in data
- ? data[record.posType as keyof typeof data]
- : "";
- },
- },
- {
- title: t("posPage.posInfo"),
- dataIndex: "posInfo",
- key: "posInfo",
- editable: true,
- align: "center",
- fieldConfig: {
- render: (_, formIns) => {
- return ;
- },
- },
- },
- {
- title: t("posPage.exclude"),
- dataIndex: "exclude",
- key: "exclude",
- editable: true,
- align: "center",
- render: (value) => {
- return ;
- },
- fieldConfig: {
- type: "Switch",
- formOptions: {
- name: "exclude",
- style: {
- margin: 0,
- },
- valuePropName: "checked",
- initialValue: false,
- },
- },
- },
- {
- title: t("posPage.weight"),
- dataIndex: "weight",
- key: "weight",
- editable: true,
- align: "center",
- fieldConfig: {
- render: (_, formIns) => {
- const { posType, agentOrAirline, officeOwner, exclude } =
- form.getFieldsValue();
- const weightValue = calcWeight({
- posType,
- agentOrAirline,
- officeOwner,
- exclude,
- });
- useEffect(() => {
- formIns.setFieldValue("weight", weightValue);
- }, [weightValue]);
- return (
-
- {calcWeight({
- posType,
- agentOrAirline,
- officeOwner,
- exclude,
- })}
-
- );
- },
- },
- render: (value) => {
- return {value}
;
- },
- },
-
- ];
- if(isDetail){
- data.concat( {
- title: t("posPage.operation"),
- dataIndex: "operation",
- align: "center",
- render: (_: any, record) => {
- const editable = isEditing(record);
- return editable ? (
-
- {
- setIsEditing(false);
- save(record.uid!);
- }}
- style={{ marginRight: 8 }}
- >
- {/* Save */}
-
-
- {
- setIsEditing(false);
- cancel();
- }}
- okText={commonT`blog.Yes`}
- cancelText={commonT`blog.No`}
- >
- {/* Cancel */}
-
-
-
- ) : (
-
- {
- edit(record);
- setIsEditing(true);
- }}
- style={{ marginRight: 8 }}
- >
- {/* Edit */}
-
-
-
- {
- deleteByKey(record.uid!);
- }}
- okText={commonT`blog.Yes`}
- cancelText={commonT`blog.No`}
- >
- {/* Delete */}
-
-
-
-
- );
- },
- },)
- }
- return data;
+ const { t } = useTranslation(["pos"]);
+ const { t: commonT } = useTranslation(["common"]);
+ const { setIsEditing } = useFlat(["posStore", extra?.branchName]);
+ const isDetail = extra?.branchName == ROUTE_ID.PosDetailPage;
+ let data: MyColumnType[] = [
+ {
+ title: t("posPage.posType"),
+ dataIndex: "posType",
+ key: "posType",
+ editable: true,
+ align: "center",
+ fieldConfig: {
+ options: [
+ {
+ key: "I",
+ value: "I",
+ label: t("posPage.IATANUM"),
+ },
+ {
+ key: "T",
+ value: "T",
+ label: t("posPage.PCC"),
+ },
+ ],
+ inputAttrConfig: {
+ placeholder: `${t("posPage.placeholder_select")} ${t(
+ "posPage.posType",
+ )}`,
+ maxLength: 60,
+ style: {
+ width: "140px",
+ },
+ },
+ type: "Select",
+ render: ({ inputAttrConfig, options }, form) => {
+ console.log("form.getFieldValue()");
+ console.log(form.getFieldValue("posType"));
+ const optionArr =
+ typeof options == "function" ? options() : options;
+ return (
+
+
+
+ );
+ },
+ },
+ render: (_, record) => {
+ let data = {
+ I: t("posPage.IATANUM"),
+ T: t("posPage.PCC"),
+ };
+ return record.posType in data
+ ? data[record.posType as keyof typeof data]
+ : "";
+ },
+ },
+ {
+ title: t("posPage.posInfo"),
+ dataIndex: "posInfo",
+ key: "posInfo",
+ editable: true,
+ align: "center",
+ fieldConfig: {
+ render: (_, formIns) => {
+ return ;
+ },
+ },
+ },
+ {
+ title: t("posPage.exclude"),
+ dataIndex: "exclude",
+ key: "exclude",
+ editable: true,
+ align: "center",
+ render: (value) => {
+ return ;
+ },
+ fieldConfig: {
+ type: "Switch",
+ formOptions: {
+ name: "exclude",
+ style: {
+ margin: 0,
+ },
+ valuePropName: "checked",
+ initialValue: false,
+ },
+ },
+ },
+ {
+ title: t("posPage.weight"),
+ dataIndex: "weight",
+ key: "weight",
+ editable: true,
+ align: "center",
+ fieldConfig: {
+ render: (_, formIns) => {
+ const { posType, agentOrAirline, officeOwner, exclude } =
+ form.getFieldsValue();
+ const weightValue = calcWeight({
+ posType,
+ agentOrAirline,
+ officeOwner,
+ exclude,
+ });
+ useEffect(() => {
+ formIns.setFieldValue("weight", weightValue);
+ }, [weightValue]);
+ return (
+
+ {calcWeight({
+ posType,
+ agentOrAirline,
+ officeOwner,
+ exclude,
+ })}
+
+ );
+ },
+ },
+ render: (value) => {
+ return {value}
;
+ },
+ },
+ ];
+ if (!isDetail) {
+ data = data.concat({
+ title: t("posPage.operation"),
+ dataIndex: "operation",
+ align: "center",
+ render: (_: any, record) => {
+ const editable = isEditing(record);
+ return editable ? (
+
+ {
+ setIsEditing(false);
+ save(record.uid!);
+ }}
+ style={{ marginRight: 8 }}
+ >
+ {/* Save */}
+
+
+ {
+ setIsEditing(false);
+ cancel();
+ }}
+ okText={commonT`blog.Yes`}
+ cancelText={commonT`blog.No`}
+ >
+ {/* Cancel */}
+
+
+
+ ) : (
+
+ {
+ edit(record);
+ setIsEditing(true);
+ }}
+ style={{ marginRight: 8 }}
+ >
+ {/* Edit */}
+
+
+
+ {
+ deleteByKey(record.uid!);
+ }}
+ okText={commonT`blog.Yes`}
+ cancelText={commonT`blog.No`}
+ >
+ {/* Delete */}
+
+
+
+
+ );
+ },
+ });
+ }
+ return data;
};
export default columnsCreater;
diff --git a/frontend/packages/admin-antd/src/pages/HomePage/CpdPage/PosPage/components/posItemsTable/index.tsx b/frontend/packages/admin-antd/src/pages/HomePage/CpdPage/PosPage/components/posItemsTable/index.tsx
index 464165c9..040dd705 100644
--- a/frontend/packages/admin-antd/src/pages/HomePage/CpdPage/PosPage/components/posItemsTable/index.tsx
+++ b/frontend/packages/admin-antd/src/pages/HomePage/CpdPage/PosPage/components/posItemsTable/index.tsx
@@ -9,83 +9,83 @@ import type { PosItem } from "src/service/stores/posStore/model";
import columnsCreater from "./columnsCreater";
const WrapperComp: Wrapper = ({
- children,
- editingKey,
- dataList,
- edit,
- branchName,
+ children,
+ editingKey,
+ dataList,
+ edit,
+ branchName,
}) => {
- const { t } = useTranslation(["pos"]);
- const { t: commonT } = useTranslation(["common"]);
- const { currentData, setCurrentDetail } = useFlat(["posStore", branchName]);
- return (
- <>
- {children}
- {" "}
- >
- );
+ const { t } = useTranslation(["pos"]);
+ const { t: commonT } = useTranslation(["common"]);
+ const { currentData, setCurrentDetail } = useFlat(["posStore", branchName]);
+ return (
+ <>
+ {children}
+ {" "}
+ >
+ );
};
const PosItemsTable = ({ branchName }: { branchName: string }) => {
- const { currentData, setCurrentDetail } = useFlat(
- ["posStore", branchName],
- {
- currentData: "IN",
- }
- );
- const { t } = useTranslation(["pos"]);
- return (
- <>
-
- {t("posPage.itemListTitle")}
-
-
- columnCreater={(props) => {
- return columnsCreater(props, { branchName });
- }}
- values={currentData?.cpdPosItems || []}
- Wrapper={(props) => {
- return ;
- }}
- handleValuesChange={({ allData }) => {
- setCurrentDetail({
- ...currentData!,
- cpdPosItems: allData,
- });
- }}
- />
- >
- );
+ const { currentData, setCurrentDetail } = useFlat(
+ ["posStore", branchName],
+ {
+ currentData: "IN",
+ },
+ );
+ const { t } = useTranslation(["pos"]);
+ return (
+ <>
+
+ {t("posPage.itemListTitle")}
+
+
+ columnCreater={(props) => {
+ return columnsCreater(props, { branchName });
+ }}
+ values={currentData?.cpdPosItems || []}
+ Wrapper={(props) => {
+ return ;
+ }}
+ handleValuesChange={({ allData }) => {
+ setCurrentDetail({
+ ...currentData!,
+ cpdPosItems: allData,
+ });
+ }}
+ />
+ >
+ );
};
export default PosItemsTable;