|
@@ -1,12 +1,13 @@
|
|
|
import { useAjax } from "@/Hook/useAjax";
|
|
|
-import { delWechatAppletApi, getWechatAppletAllApi, getWechatAppletApi, getWechatAppletDetailApi } from "@/services/adqV3/global";
|
|
|
-import { PlusOutlined, SearchOutlined } from "@ant-design/icons";
|
|
|
-import { Button, Card, Divider, Input, message, Select, Table, Typography } from "antd";
|
|
|
+import { delWechatAppletApi, downloadTemplateApi, getWechatAppletAllApi, getWechatAppletApi, getWechatAppletDetailApi, importExcelApi } from "@/services/adqV3/global";
|
|
|
+import { CloudDownloadOutlined, CloudUploadOutlined, PlusOutlined, SearchOutlined } from "@ant-design/icons";
|
|
|
+import { Button, Card, Divider, Input, message, Select, Table, Typography, Upload } from "antd";
|
|
|
import React, { useEffect, useState } from "react"
|
|
|
import '../../tencentAdPutIn/index.less'
|
|
|
import Modify from "./modify";
|
|
|
import columns from "./tableConfig";
|
|
|
-const { Text, Link, Paragraph } = Typography;
|
|
|
+import { downloadFile1, formatDate } from "@/utils/downloadFile";
|
|
|
+const { Text, Paragraph } = Typography;
|
|
|
|
|
|
/**
|
|
|
* 微信小程序
|
|
@@ -19,9 +20,12 @@ const MiniProgramWechat: React.FC = () => {
|
|
|
const [queryFormNew, setQueryFormNew] = useState<{ pageNum: number, pageSize: number, appletName?: string, appletIdList?: string[] }>({ pageNum: 1, pageSize: 20 })
|
|
|
const [visible, setVisible] = useState<boolean>(false)
|
|
|
const [initialValues, setInitialValues] = useState<any>({})
|
|
|
+ const [downLoading, setDownLoading] = useState<boolean>(false)
|
|
|
+ const [btnUploadLoding, setBtnUploadLoding] = useState<boolean>(false)//按钮loding
|
|
|
|
|
|
const getWechatApplet = useAjax((params) => getWechatAppletApi(params))
|
|
|
const delWechatApplet = useAjax((params) => delWechatAppletApi(params))
|
|
|
+ const importExcel = useAjax((params) => importExcelApi(params))
|
|
|
/**********************************/
|
|
|
|
|
|
useEffect(() => {
|
|
@@ -63,6 +67,41 @@ const MiniProgramWechat: React.FC = () => {
|
|
|
/>
|
|
|
<Button type="primary" icon={<SearchOutlined />} onClick={() => setQueryFormNew({ ...queryForm })}>搜索</Button>
|
|
|
<Button type="primary" icon={<PlusOutlined />} onClick={() => { setVisible(true) }}>新增小程序</Button>
|
|
|
+ <Button
|
|
|
+ icon={<CloudDownloadOutlined />}
|
|
|
+ loading={downLoading}
|
|
|
+ onClick={() => {
|
|
|
+ setDownLoading(true)
|
|
|
+ downloadTemplateApi().then(res => {
|
|
|
+ setDownLoading(false)
|
|
|
+ downloadFile1(res, 'octet-stream', formatDate(new Date()) + ".xlsx")
|
|
|
+ }).catch(() => setDownLoading(false))
|
|
|
+ }}
|
|
|
+ >下载模板</Button>
|
|
|
+ <Upload
|
|
|
+ accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
|
|
|
+ action=""
|
|
|
+ listType="text"
|
|
|
+ onChange={() => { }}
|
|
|
+ multiple={true}
|
|
|
+ showUploadList={false}
|
|
|
+ customRequest={(options) => {
|
|
|
+ setBtnUploadLoding(true)
|
|
|
+ let formData = new FormData();
|
|
|
+ formData.append("file", options.file);
|
|
|
+ importExcel.run(formData).then(res => {
|
|
|
+ setBtnUploadLoding(false)
|
|
|
+ if (res) {
|
|
|
+ message.success('导入成功')
|
|
|
+ getWechatApplet.refresh()
|
|
|
+ }
|
|
|
+ }).catch(() => {
|
|
|
+ setBtnUploadLoding(false)
|
|
|
+ })
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ <Button type="primary" ghost loading={btnUploadLoding} icon={<CloudUploadOutlined />} onClick={() => { }}>上传Excel</Button>
|
|
|
+ </Upload>
|
|
|
</div>}
|
|
|
>
|
|
|
|