|
@@ -1,8 +1,8 @@
|
|
import BreadTit from "@/components/BreadTit";
|
|
import BreadTit from "@/components/BreadTit";
|
|
import { RootState } from "@/store";
|
|
import { RootState } from "@/store";
|
|
-import { Button, Input, Pagination, Select, Table } from "antd";
|
|
|
|
-import { useEffect, useMemo, useRef, useState } from "react";
|
|
|
|
-import { useSelector } from "react-redux";
|
|
|
|
|
|
+import { Button, Input, message, Pagination, Select, Table } from "antd";
|
|
|
|
+import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
|
|
+import { useDispatch, useSelector } from "react-redux";
|
|
import styles from "./index.module.scss";
|
|
import styles from "./index.module.scss";
|
|
import { UnorderedListOutlined, AppstoreOutlined } from "@ant-design/icons";
|
|
import { UnorderedListOutlined, AppstoreOutlined } from "@ant-design/icons";
|
|
import classNames from "classnames";
|
|
import classNames from "classnames";
|
|
@@ -11,17 +11,29 @@ import history from "@/utils/history";
|
|
import { useLocation } from "react-router-dom";
|
|
import { useLocation } from "react-router-dom";
|
|
import dayjs from "dayjs";
|
|
import dayjs from "dayjs";
|
|
import ExportJsonExcel from "js-export-excel";
|
|
import ExportJsonExcel from "js-export-excel";
|
|
|
|
+import { getObject2List } from "@/store/action/object2";
|
|
|
|
+import http from "@/utils/http";
|
|
const { Option } = Select;
|
|
const { Option } = Select;
|
|
export default function Object2() {
|
|
export default function Object2() {
|
|
|
|
+ const dispatch = useDispatch();
|
|
|
|
+
|
|
// 从仓库中获取藏品编号名称下拉数据
|
|
// 从仓库中获取藏品编号名称下拉数据
|
|
const options = useSelector(
|
|
const options = useSelector(
|
|
(state: RootState) => state.loginStore.selectAll["藏品编号名称"]
|
|
(state: RootState) => state.loginStore.selectAll["藏品编号名称"]
|
|
);
|
|
);
|
|
|
|
|
|
|
|
+ // 从仓库中获取表格数据(图片展示数据)
|
|
|
|
+ const results = useSelector((state: RootState) => state.object2Store.info2);
|
|
|
|
+
|
|
// 封装发送请求的函数
|
|
// 封装发送请求的函数
|
|
const getList = () => {
|
|
const getList = () => {
|
|
- const data = { ...tableSelect, pageNum: pageNumRef.current, aaaaa: value };
|
|
|
|
- console.log("------", data);
|
|
|
|
|
|
+ const data = {
|
|
|
|
+ ...tableSelect,
|
|
|
|
+ pageNum: pageNumRef.current,
|
|
|
|
+ searchType: value,
|
|
|
|
+ };
|
|
|
|
+ dispatch(getObject2List(data));
|
|
|
|
+ // console.log("------", data);
|
|
};
|
|
};
|
|
|
|
|
|
// 获取地址栏参数
|
|
// 获取地址栏参数
|
|
@@ -37,11 +49,35 @@ export default function Object2() {
|
|
|
|
|
|
// 筛选表格的数据
|
|
// 筛选表格的数据
|
|
const [tableSelect, setTableSelect] = useState<any>({
|
|
const [tableSelect, setTableSelect] = useState<any>({
|
|
- bianhao: null,
|
|
|
|
- name: "",
|
|
|
|
|
|
+ dictNum: null,
|
|
|
|
+ searchKey: "",
|
|
pageSize: 10,
|
|
pageSize: 10,
|
|
pageNum: 1,
|
|
pageNum: 1,
|
|
});
|
|
});
|
|
|
|
+
|
|
|
|
+ // 图片页面和列表页面的切换
|
|
|
|
+ const [cutShow, setCutShow] = useState("cutShow1");
|
|
|
|
+
|
|
|
|
+ // 当前图片查看或者表格查看数据统一
|
|
|
|
+
|
|
|
|
+ const cutShowRef = useRef("1");
|
|
|
|
+
|
|
|
|
+ // 进页面如果 d的值为2 切换到表格显示
|
|
|
|
+ useEffect(() => {
|
|
|
|
+ const urlParam = location.state || {};
|
|
|
|
+ if (urlParam.d && urlParam.d === "2") {
|
|
|
|
+ cutShowRef.current = "2";
|
|
|
|
+ window.setTimeout(() => {
|
|
|
|
+ setCutShow("cutShow2");
|
|
|
|
+ }, 20);
|
|
|
|
+ }
|
|
|
|
+ }, [location.state]);
|
|
|
|
+
|
|
|
|
+ const cutShowFu = useCallback((val: string) => {
|
|
|
|
+ cutShowRef.current = val === "cutShow1" ? "1" : "2";
|
|
|
|
+ setCutShow(val);
|
|
|
|
+ }, []);
|
|
|
|
+
|
|
// 当前页码统一
|
|
// 当前页码统一
|
|
const pageNumRef = useRef(1);
|
|
const pageNumRef = useRef(1);
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
@@ -62,76 +98,65 @@ export default function Object2() {
|
|
|
|
|
|
// 藏品来源下拉框改变
|
|
// 藏品来源下拉框改变
|
|
const handleChange = (val: string) => {
|
|
const handleChange = (val: string) => {
|
|
- setTableSelect({ ...tableSelect, bianhao: val, pageNum: 1 });
|
|
|
|
|
|
+ setTableSelect({ ...tableSelect, dictNum: val, pageNum: 1 });
|
|
};
|
|
};
|
|
|
|
|
|
// 搜索输入框下拉
|
|
// 搜索输入框下拉
|
|
- const [value, setValue] = useState("name1");
|
|
|
|
|
|
+ const [value, setValue] = useState("name");
|
|
const valueChangeFu = (val: string) => {
|
|
const valueChangeFu = (val: string) => {
|
|
|
|
+ if (tableSelect.searchKey) {
|
|
|
|
+ // 根据输入框的值重新发送请求
|
|
|
|
+ setTableSelect({ ...tableSelect, searchType: val });
|
|
|
|
+ }
|
|
|
|
+
|
|
setValue(val);
|
|
setValue(val);
|
|
};
|
|
};
|
|
const nameTime = useRef(-1);
|
|
const nameTime = useRef(-1);
|
|
const nameChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
const nameChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
clearTimeout(nameTime.current);
|
|
clearTimeout(nameTime.current);
|
|
nameTime.current = window.setTimeout(() => {
|
|
nameTime.current = window.setTimeout(() => {
|
|
- setTableSelect({ ...tableSelect, name: e.target.value, pageNum: 1 });
|
|
|
|
|
|
+ setTableSelect({ ...tableSelect, searchKey: e.target.value, pageNum: 1 });
|
|
}, 500);
|
|
}, 500);
|
|
};
|
|
};
|
|
|
|
|
|
- // 图片页面和列表页面的切换
|
|
|
|
- const [cutShow, setCutShow] = useState("cutShow1");
|
|
|
|
-
|
|
|
|
// 关于表格的数据
|
|
// 关于表格的数据
|
|
const paginationChange = (pageNum: number, pageSize: number) => {
|
|
const paginationChange = (pageNum: number, pageSize: number) => {
|
|
setTableSelect({ ...tableSelect, pageNum, pageSize });
|
|
setTableSelect({ ...tableSelect, pageNum, pageSize });
|
|
};
|
|
};
|
|
|
|
|
|
- const results = {
|
|
|
|
- list: [
|
|
|
|
- { img: "", name: "666-1", id: 1 },
|
|
|
|
- {
|
|
|
|
- img: "http://project.4dage.com:8016/content/1_1001/img/20220810_1553241331042.JPG",
|
|
|
|
- name: "666-2",
|
|
|
|
- id: 2,
|
|
|
|
- },
|
|
|
|
- { img: "", name: "sada阿三大苏打sada阿三大苏打-3", id: 3 },
|
|
|
|
- { img: "", name: "666-4", id: 4 },
|
|
|
|
- { img: "", name: "666-5", id: 5 },
|
|
|
|
- { img: "", name: "666-6", id: 6 },
|
|
|
|
- { img: "", name: "666-7", id: 7 },
|
|
|
|
- { img: "", name: "666-8", id: 8 },
|
|
|
|
- { img: "", name: "666-9", id: 9 },
|
|
|
|
- { img: "", name: "666-10", id: 10 },
|
|
|
|
- { img: "", name: "666-11", id: 11 },
|
|
|
|
- { img: "", name: "666-12", id: 12 },
|
|
|
|
- { img: "", name: "666-13", id: 13 },
|
|
|
|
- { img: "", name: "666-14", id: 14 },
|
|
|
|
- { img: "", name: "666-15", id: 15 },
|
|
|
|
- { img: "", name: "666-16", id: 16 },
|
|
|
|
- { img: "", name: "666-17", id: 17 },
|
|
|
|
- { img: "", name: "666-18", id: 18 },
|
|
|
|
- { img: "", name: "666-19", id: 19 },
|
|
|
|
- { img: "", name: "666-20", id: 20 },
|
|
|
|
- { img: "", name: "666-21", id: 21 },
|
|
|
|
- { img: "", name: "666-22", id: 22 },
|
|
|
|
- { img: "", name: "666-23", id: 23 },
|
|
|
|
- ],
|
|
|
|
- total: 23,
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
const columns = useMemo(() => {
|
|
const columns = useMemo(() => {
|
|
return [
|
|
return [
|
|
{
|
|
{
|
|
title: "缩略图",
|
|
title: "缩略图",
|
|
render: (item: any) => (
|
|
render: (item: any) => (
|
|
- <ImageLazy width={120} height={70} src={item.img} />
|
|
|
|
|
|
+ <ImageLazy width={120} height={70} src={item.thumb} />
|
|
),
|
|
),
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- title: "标题",
|
|
|
|
|
|
+ title: "藏品编号名称",
|
|
|
|
+ dataIndex: "dictNum",
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: "藏品编号",
|
|
|
|
+ render: (item: any) => (item.num ? item.num : "-"),
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: "藏品名称",
|
|
dataIndex: "name",
|
|
dataIndex: "name",
|
|
},
|
|
},
|
|
{
|
|
{
|
|
|
|
+ title: "年代",
|
|
|
|
+ dataIndex: "dictAge",
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: "质地",
|
|
|
|
+ dataIndex: "dictTexture",
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: "状态",
|
|
|
|
+ dataIndex: "storageStatusTxt",
|
|
|
|
+ },
|
|
|
|
+ {
|
|
title: "操作",
|
|
title: "操作",
|
|
render: (item: any) => (
|
|
render: (item: any) => (
|
|
<>
|
|
<>
|
|
@@ -140,7 +165,7 @@ export default function Object2() {
|
|
danger
|
|
danger
|
|
onClick={() =>
|
|
onClick={() =>
|
|
history.push(
|
|
history.push(
|
|
- `/object/2/look?k=${pageNumRef.current}&id=${item.id}`
|
|
|
|
|
|
+ `/object/2/look?k=${pageNumRef.current}&d=${cutShowRef.current}&id=${item.id}`
|
|
)
|
|
)
|
|
}
|
|
}
|
|
>
|
|
>
|
|
@@ -154,23 +179,109 @@ export default function Object2() {
|
|
}, []);
|
|
}, []);
|
|
|
|
|
|
// 点击导出
|
|
// 点击导出
|
|
- const deriveFu = () => {
|
|
|
|
|
|
+ const deriveFu = useCallback(async () => {
|
|
|
|
+ if (results.list.length === 0)
|
|
|
|
+ return message.warning("当前搜索条件没有数据!");
|
|
const name = dayjs(new Date()).format("YYYYMMDDHHmmss");
|
|
const name = dayjs(new Date()).format("YYYYMMDDHHmmss");
|
|
|
|
+ const res = await http.post("cms/ledger/pageList", {
|
|
|
|
+ ...tableSelect,
|
|
|
|
+ pageSize: 9999,
|
|
|
|
+ searchType: value,
|
|
|
|
+ });
|
|
|
|
+ const sheetData = res.data.records;
|
|
|
|
+ sheetData.forEach((v: any) => {
|
|
|
|
+ if (v.size && v.size.length) {
|
|
|
|
+ const sizeArr = v.size.split(",");
|
|
|
|
+ v.sizeRes = `(通长)${sizeArr[0]}cm;(通宽)${sizeArr[1]}cm;(通高)${sizeArr[2]}cm`;
|
|
|
|
+ }
|
|
|
|
+ v.qualityRes = "-";
|
|
|
|
+ if (v.quality && v.quality.length) {
|
|
|
|
+ const qualityArr = v.quality.split(",");
|
|
|
|
+ v.qualityRes = qualityArr[0] + qualityArr[1];
|
|
|
|
+ }
|
|
|
|
+ v.namePrimitive = v.namePrimitive ? v.namePrimitive : "-";
|
|
|
|
+ v.num = v.num ? v.num : "-";
|
|
|
|
+ v.ageSpecific = v.ageSpecific ? v.ageSpecific : "-";
|
|
|
|
+ v.repair = v.repair ? v.repair : "-";
|
|
|
|
+ v.checkInYear = v.checkInYear ? v.checkInYear : "-";
|
|
|
|
+ v.author = v.author ? v.author : "-";
|
|
|
|
+ v.vision = v.vision ? v.vision : "-";
|
|
|
|
+ v.onFile = v.onFile ? v.onFile : "-";
|
|
|
|
+ v.description = v.description ? v.description : "-";
|
|
|
|
+ v.storageAncestorName = v.storageAncestorName
|
|
|
|
+ ? v.storageAncestorName
|
|
|
|
+ : "-";
|
|
|
|
+ v.outLocation = v.outLocation ? v.outLocation : "-";
|
|
|
|
+ });
|
|
const option = {
|
|
const option = {
|
|
fileName: name,
|
|
fileName: name,
|
|
datas: [
|
|
datas: [
|
|
{
|
|
{
|
|
- sheetData: results.list,
|
|
|
|
|
|
+ sheetData,
|
|
sheetName: name,
|
|
sheetName: name,
|
|
- sheetFilter: ["img", "name", "id"],
|
|
|
|
- sheetHeader: ["图片", "名字", "id"],
|
|
|
|
- // columnWidths: [10, 10, 10],
|
|
|
|
|
|
+ sheetFilter: [
|
|
|
|
+ "name",
|
|
|
|
+ "namePrimitive",
|
|
|
|
+ "dictNum",
|
|
|
|
+ "num",
|
|
|
|
+ "dictAge",
|
|
|
|
+ "dictTexture",
|
|
|
|
+ "ageSpecific",
|
|
|
|
+ "dictGoodType",
|
|
|
|
+ "pcs",
|
|
|
|
+ "dictLevel",
|
|
|
|
+ "sizeRes",
|
|
|
|
+ "sizeSpecific",
|
|
|
|
+ "dictQualityScope",
|
|
|
|
+ "qualityRes",
|
|
|
|
+ "complete",
|
|
|
|
+ "repair",
|
|
|
|
+ "dictCheckInScope",
|
|
|
|
+ "checkInYear",
|
|
|
|
+ "author",
|
|
|
|
+ "vision",
|
|
|
|
+ "onFile",
|
|
|
|
+ "description",
|
|
|
|
+ "storageAncestorName",
|
|
|
|
+ "outLocation",
|
|
|
|
+ ],
|
|
|
|
+ sheetHeader: [
|
|
|
|
+ "藏品名称",
|
|
|
|
+ "原名",
|
|
|
|
+ "藏品编号名称",
|
|
|
|
+ "藏品编号",
|
|
|
|
+ "年代",
|
|
|
|
+ "文物质地",
|
|
|
|
+ "具体年代",
|
|
|
|
+ "文物类别",
|
|
|
|
+ "实际数量",
|
|
|
|
+ "文物级别",
|
|
|
|
+ "外形尺寸",
|
|
|
|
+ "具体尺寸",
|
|
|
|
+ "质量范围",
|
|
|
|
+ "具体质量",
|
|
|
|
+ "完残程度",
|
|
|
|
+ "保存状态",
|
|
|
|
+ "入藏时间范围",
|
|
|
|
+ "入藏年度",
|
|
|
|
+ "著者",
|
|
|
|
+ "版本",
|
|
|
|
+ "存卷",
|
|
|
|
+ "来源说明",
|
|
|
|
+ "入库位置",
|
|
|
|
+ "出库位置",
|
|
|
|
+ ],
|
|
|
|
+ columnWidths: [
|
|
|
|
+ 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
|
|
|
+ 10, 10, 10, 10, 10, 10, 10,
|
|
|
|
+ ],
|
|
},
|
|
},
|
|
],
|
|
],
|
|
};
|
|
};
|
|
|
|
+
|
|
const toExcel = new ExportJsonExcel(option); //new
|
|
const toExcel = new ExportJsonExcel(option); //new
|
|
toExcel.saveExcel(); //保存
|
|
toExcel.saveExcel(); //保存
|
|
- };
|
|
|
|
|
|
+ }, [results.list, tableSelect, value]);
|
|
|
|
|
|
return (
|
|
return (
|
|
<div className={styles.Object2}>
|
|
<div className={styles.Object2}>
|
|
@@ -188,7 +299,7 @@ export default function Object2() {
|
|
placeholder="请选择"
|
|
placeholder="请选择"
|
|
allowClear
|
|
allowClear
|
|
style={{ width: 150 }}
|
|
style={{ width: 150 }}
|
|
- value={tableSelect.bianhao}
|
|
|
|
|
|
+ value={tableSelect.dictNum}
|
|
onChange={handleChange}
|
|
onChange={handleChange}
|
|
options={options.map((v: any) => ({
|
|
options={options.map((v: any) => ({
|
|
label: v.name,
|
|
label: v.name,
|
|
@@ -203,9 +314,9 @@ export default function Object2() {
|
|
value={value}
|
|
value={value}
|
|
onChange={(val) => valueChangeFu(val)}
|
|
onChange={(val) => valueChangeFu(val)}
|
|
>
|
|
>
|
|
- <Option value="name1">藏品名称</Option>
|
|
|
|
- <Option value="name2">藏品年代</Option>
|
|
|
|
- <Option value="name3">藏品质地</Option>
|
|
|
|
|
|
+ <Option value="name">藏品名称</Option>
|
|
|
|
+ <Option value="age">藏品年代</Option>
|
|
|
|
+ <Option value="texture">藏品质地</Option>
|
|
</Select>
|
|
</Select>
|
|
<Input
|
|
<Input
|
|
maxLength={10}
|
|
maxLength={10}
|
|
@@ -220,7 +331,7 @@ export default function Object2() {
|
|
</div>
|
|
</div>
|
|
<div className="row">
|
|
<div className="row">
|
|
<div
|
|
<div
|
|
- onClick={() => setCutShow("cutShow1")}
|
|
|
|
|
|
+ onClick={() => cutShowFu("cutShow1")}
|
|
className={classNames(
|
|
className={classNames(
|
|
"cutShow",
|
|
"cutShow",
|
|
cutShow === "cutShow1" ? "active" : ""
|
|
cutShow === "cutShow1" ? "active" : ""
|
|
@@ -229,7 +340,7 @@ export default function Object2() {
|
|
<AppstoreOutlined />
|
|
<AppstoreOutlined />
|
|
</div>
|
|
</div>
|
|
<div
|
|
<div
|
|
- onClick={() => setCutShow("cutShow2")}
|
|
|
|
|
|
+ onClick={() => cutShowFu("cutShow2")}
|
|
className={classNames(
|
|
className={classNames(
|
|
"cutShow",
|
|
"cutShow",
|
|
"cutShow2",
|
|
"cutShow2",
|
|
@@ -242,21 +353,31 @@ export default function Object2() {
|
|
</div>
|
|
</div>
|
|
{/* 图片展示列表 */}
|
|
{/* 图片展示列表 */}
|
|
<div className="imgList" hidden={cutShow !== "cutShow1"}>
|
|
<div className="imgList" hidden={cutShow !== "cutShow1"}>
|
|
- {results.list.map((v) => (
|
|
|
|
- <div
|
|
|
|
- title="666666"
|
|
|
|
- onClick={() =>
|
|
|
|
- history.push(
|
|
|
|
- `/object/2/look?k=${pageNumRef.current}&id=${v.id}`
|
|
|
|
- )
|
|
|
|
- }
|
|
|
|
- key={v.id}
|
|
|
|
- className="imgListRow"
|
|
|
|
- >
|
|
|
|
- <ImageLazy noLook={true} width={193} height={190} src={v.img} />
|
|
|
|
- <p>{v.name}</p>
|
|
|
|
- </div>
|
|
|
|
- ))}
|
|
|
|
|
|
+ {results.list.length ? (
|
|
|
|
+ results.list.map((v: any) => (
|
|
|
|
+ <div
|
|
|
|
+ title={v.name}
|
|
|
|
+ onClick={() =>
|
|
|
|
+ history.push(
|
|
|
|
+ `/object/2/look?k=${pageNumRef.current}&d=${cutShowRef.current}&id=${v.id}`
|
|
|
|
+ )
|
|
|
|
+ }
|
|
|
|
+ key={v.id}
|
|
|
|
+ className="imgListRow"
|
|
|
|
+ >
|
|
|
|
+ <ImageLazy
|
|
|
|
+ noLook={true}
|
|
|
|
+ width={193}
|
|
|
|
+ height={190}
|
|
|
|
+ src={v.thumb}
|
|
|
|
+ />
|
|
|
|
+ <p>{v.name}</p>
|
|
|
|
+ </div>
|
|
|
|
+ ))
|
|
|
|
+ ) : (
|
|
|
|
+ <div className="imgListNone">暂无数据</div>
|
|
|
|
+ )}
|
|
|
|
+ {}
|
|
</div>
|
|
</div>
|
|
|
|
|
|
{/* 表格展示列表 */}
|
|
{/* 表格展示列表 */}
|