import React, { Fragment, useRef, useMemo,useEffect,useState } from 'react';
import BasicCrudModal from '../../../../components/crud/BasicCrudModal';
import { Upload, message,Image,Button,Popconfirm,Modal } from 'antd';
import {PaperClipOutlined,DownloadOutlined,DeleteOutlined,ExclamationCircleOutlined } from '@ant-design/icons';
import { useSelector } from 'react-redux';
import ToolBar from './toolbar';
import ModalForm from './form';
import apiurl from '../../../../service/apiurl';
import { httpget2,httppost2 } from '../../../../utils/request';
import "./index.less"
const { confirm } = Modal;
const url = "http://223.75.53.141:9100/gs-tsg"
const Page = () => {
const role = useSelector(state => state.auth.role);
console.log("role",role);
const uploadBtn = role?.rule?.find(item => item.menuName == "上传") || true;
const refModal = useRef();
const [fileList, setFileList] = useState([]) //上传文件列表
const [loading, setLoading] = useState(false)
const [zlList, setZlList] = useState([])
const [data, setData] = useState([])
const fileType = {
"jpg": 'pic',
"png": 'pic',
"jpeg": 'pic',
"gif": 'gif',
"xlsx": 'excel',
"xls": 'excel',
"doc": 'word',
"docx": 'word',
"ppt": 'PPT',
"pptx": 'PPT',
"pdf": 'pdf',
}
const iconFile = (name) => {
let icon;
const type = name.split('.').pop();
icon = fileType[type]
return icon
}
const fileChange = (info) => {
if (info.file.status === "done") {
setLoading(false);
getFileList()
}
if (info.file.status === "uploading") {
setLoading(true);
}
if (info.file.status === "error") {
message.error("文件上传失败")
setLoading(false);
}
setFileList(info.fileList)
}
const getFileList = async () => {
try {
const res = await httpget2(apiurl.rcgl.byfz.fzxc.list)
if (res.code == 200) {
setZlList(res.data)
}
} catch (error) {
console.log(error);
}
}
const getPicList = async () => {
try {
const res = await httppost2(apiurl.rcgl.byfz.fzxc.picList)
if (res.code == 200) {
setData(res.data)
}
} catch (error) {
console.log(error);
}
}
const download = (params) => {
let downloadLink = document.createElement("a");
downloadLink.href = `http://local.gunshiiot.com:18083/gunshiApp/tsg/termite/adver/file/download/${params}`;
downloadLink.download = `${params.fileName}`;
downloadLink.style.display = "none";
// 将链接添加到页面中
document.body.appendChild(downloadLink);
// 模拟点击事件,开始下载
downloadLink.click();
}
const deleteFile = async (id, type) => {
const urlRequest = type == "file" ? apiurl.rcgl.byfz.fzxc.delete : apiurl.rcgl.byfz.fzxc.picDelete
confirm({
title: '删除',
icon:
宣传图片墙
{uploadBtn ? : null}