|
@@ -19,6 +19,24 @@ import RelationEdit from "../../../components/admin/relation/RelationEdit";
|
|
|
import DataImport from "../../../components/admin/relation/DataImport";
|
|
import DataImport from "../../../components/admin/relation/DataImport";
|
|
|
import { useAppSelector } from "../../../hooks";
|
|
import { useAppSelector } from "../../../hooks";
|
|
|
import { getTerm } from "../../../reducers/term-vocabulary";
|
|
import { getTerm } from "../../../reducers/term-vocabulary";
|
|
|
|
|
+import { SortOrder } from "antd/lib/table/interface";
|
|
|
|
|
+import TimeShow from "../../../components/general/TimeShow";
|
|
|
|
|
+
|
|
|
|
|
+export const getSorterUrl = (sorter?: Record<string, SortOrder>): string => {
|
|
|
|
|
+ let url: string = "";
|
|
|
|
|
+ for (const key in sorter) {
|
|
|
|
|
+ if (Object.prototype.hasOwnProperty.call(sorter, key)) {
|
|
|
|
|
+ const element = sorter[key];
|
|
|
|
|
+ const dir = element === "ascend" ? "asc" : "desc";
|
|
|
|
|
+ let orderby = key;
|
|
|
|
|
+ if (orderby === "updatedAt") {
|
|
|
|
|
+ orderby = "updated_at";
|
|
|
|
|
+ }
|
|
|
|
|
+ url = `&order=${orderby}&dir=${dir}`;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return url;
|
|
|
|
|
+};
|
|
|
|
|
|
|
|
export const CaseValueEnum = () => {
|
|
export const CaseValueEnum = () => {
|
|
|
const intl = useIntl();
|
|
const intl = useIntl();
|
|
@@ -100,8 +118,8 @@ export interface IRelation {
|
|
|
fromCase?: string[];
|
|
fromCase?: string[];
|
|
|
fromSpell?: string;
|
|
fromSpell?: string;
|
|
|
to?: string[];
|
|
to?: string[];
|
|
|
- updatedAt?: number;
|
|
|
|
|
- createdAt?: number;
|
|
|
|
|
|
|
+ updated_at?: string;
|
|
|
|
|
+ created_at?: string;
|
|
|
}
|
|
}
|
|
|
const Widget = () => {
|
|
const Widget = () => {
|
|
|
const intl = useIntl(); //i18n
|
|
const intl = useIntl(); //i18n
|
|
@@ -163,7 +181,7 @@ const Widget = () => {
|
|
|
}),
|
|
}),
|
|
|
dataIndex: "name",
|
|
dataIndex: "name",
|
|
|
key: "name",
|
|
key: "name",
|
|
|
- sorter: (a, b) => (a < b ? 1 : -1),
|
|
|
|
|
|
|
+ sorter: true,
|
|
|
render: (text, row, index, action) => {
|
|
render: (text, row, index, action) => {
|
|
|
return (
|
|
return (
|
|
|
<RelationEdit
|
|
<RelationEdit
|
|
@@ -237,13 +255,15 @@ const Widget = () => {
|
|
|
title: intl.formatMessage({
|
|
title: intl.formatMessage({
|
|
|
id: "forms.fields.updated-at.label",
|
|
id: "forms.fields.updated-at.label",
|
|
|
}),
|
|
}),
|
|
|
- key: "updated-at",
|
|
|
|
|
|
|
+ key: "updated_at",
|
|
|
width: 100,
|
|
width: 100,
|
|
|
search: false,
|
|
search: false,
|
|
|
- dataIndex: "updatedAt",
|
|
|
|
|
|
|
+ dataIndex: "updated_at",
|
|
|
valueType: "date",
|
|
valueType: "date",
|
|
|
- sorter: (a, b) =>
|
|
|
|
|
- a.updatedAt && b.updatedAt ? a.updatedAt - b.updatedAt : 0,
|
|
|
|
|
|
|
+ sorter: true,
|
|
|
|
|
+ render: (text, row, index, action) => {
|
|
|
|
|
+ return <TimeShow time={row.updated_at} showIcon={false} />;
|
|
|
|
|
+ },
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
title: intl.formatMessage({ id: "buttons.option" }),
|
|
title: intl.formatMessage({ id: "buttons.option" }),
|
|
@@ -301,24 +321,11 @@ const Widget = () => {
|
|
|
if (filter.case) {
|
|
if (filter.case) {
|
|
|
url += `&case=${filter.case.join()}`;
|
|
url += `&case=${filter.case.join()}`;
|
|
|
}
|
|
}
|
|
|
- if (sorter) {
|
|
|
|
|
- for (const key in sorter) {
|
|
|
|
|
- if (Object.prototype.hasOwnProperty.call(sorter, key)) {
|
|
|
|
|
- const element = sorter[key];
|
|
|
|
|
- const dir = element === "ascend" ? "asc" : "desc";
|
|
|
|
|
- let orderby = key;
|
|
|
|
|
- if (orderby === "updatedAt") {
|
|
|
|
|
- orderby = "updated_at";
|
|
|
|
|
- }
|
|
|
|
|
- url += `&order=${orderby}&dir=${dir}`;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ url += getSorterUrl(sorter);
|
|
|
|
|
+
|
|
|
console.log("url", url);
|
|
console.log("url", url);
|
|
|
const res = await get<IRelationListResponse>(url);
|
|
const res = await get<IRelationListResponse>(url);
|
|
|
const items: IRelation[] = res.data.rows.map((item, id) => {
|
|
const items: IRelation[] = res.data.rows.map((item, id) => {
|
|
|
- const date = new Date(item.created_at ? item.created_at : 0);
|
|
|
|
|
- const date2 = new Date(item.updated_at ? item.updated_at : 0);
|
|
|
|
|
return {
|
|
return {
|
|
|
sn: offset + id + 1,
|
|
sn: offset + id + 1,
|
|
|
id: item.id,
|
|
id: item.id,
|
|
@@ -326,8 +333,8 @@ const Widget = () => {
|
|
|
case: item.case,
|
|
case: item.case,
|
|
|
from: item.from,
|
|
from: item.from,
|
|
|
to: item.to,
|
|
to: item.to,
|
|
|
- createdAt: date.getTime(),
|
|
|
|
|
- updatedAt: date2.getTime(),
|
|
|
|
|
|
|
+ created_at: item.created_at,
|
|
|
|
|
+ updated_at: item.updated_at,
|
|
|
};
|
|
};
|
|
|
});
|
|
});
|
|
|
console.log("relation", items);
|
|
console.log("relation", items);
|