|
|
@ -27,7 +27,7 @@ import ajax from "@/services"; |
|
|
|
import exportAjax from "@/config/ajax"; |
|
|
|
import moment from "moment"; |
|
|
|
import { useSetState } from "ahooks"; |
|
|
|
import { ResultFlow, ExportBtn, QuickMenu } from "@/components"; |
|
|
|
import { ResultFlow, ExportBtnNew, QuickMenu } from "@/components"; |
|
|
|
import "./index.scss"; |
|
|
|
import { useSessionStorageState } from 'ahooks'; |
|
|
|
import qs from 'qs'; |
|
|
@ -71,6 +71,8 @@ const TableModule = forwardRef((props, ref) => { |
|
|
|
value: {} |
|
|
|
}) |
|
|
|
|
|
|
|
const exportRef = useRef(null) |
|
|
|
|
|
|
|
//console.log(locale); |
|
|
|
const [formData, setFormData] = useState() |
|
|
|
const [inputSelectGroup, setInputSelectGroup] = useState([]) |
|
|
@ -843,81 +845,89 @@ const TableModule = forwardRef((props, ref) => { |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
const exportBtn = (filename) => { |
|
|
|
let form = { |
|
|
|
...searchForm.getFieldsValue(), |
|
|
|
...pageData, |
|
|
|
...otherData, |
|
|
|
export: filename, |
|
|
|
}; |
|
|
|
if (timeFlag) { |
|
|
|
form = { |
|
|
|
...form, |
|
|
|
timeType: timeGroup.timeType, |
|
|
|
start_time: moment(timeGroup.timeRanges.start_time).format( |
|
|
|
"YYYY-MM-DD HH:mm:ss" |
|
|
|
), |
|
|
|
end_time: moment(timeGroup.timeRanges.end_time).format( |
|
|
|
"YYYY-MM-DD HH:mm:ss" |
|
|
|
), |
|
|
|
const exportBtn = (filename, start, end) => { |
|
|
|
return new Promise((resolved, rejected) => { |
|
|
|
let form = { |
|
|
|
...searchForm.getFieldsValue(), |
|
|
|
...pageData, |
|
|
|
...otherData, |
|
|
|
export: filename, |
|
|
|
start: start, |
|
|
|
end: end |
|
|
|
}; |
|
|
|
} |
|
|
|
if (form.time) { |
|
|
|
form = { |
|
|
|
...form, |
|
|
|
time: moment(form.time).format('YYYY-MM-DD') |
|
|
|
if (timeFlag) { |
|
|
|
form = { |
|
|
|
...form, |
|
|
|
timeType: timeGroup.timeType, |
|
|
|
start_time: moment(timeGroup.timeRanges.start_time).format( |
|
|
|
"YYYY-MM-DD HH:mm:ss" |
|
|
|
), |
|
|
|
end_time: moment(timeGroup.timeRanges.end_time).format( |
|
|
|
"YYYY-MM-DD HH:mm:ss" |
|
|
|
), |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
if (areaName !== null) form[areaName] = areaSelectedList; |
|
|
|
if (form.start_time !== void 0 && form.end_time !== void 0) { |
|
|
|
form.start_time = moment(form.start_time).format("YYYY-MM-DD HH:mm:ss"); |
|
|
|
form.end_time = moment(form.end_time).format("YYYY-MM-DD HH:mm:ss"); |
|
|
|
if (exportUrl == "/api/ope/record/recharge_export") { //特殊情况,用户信息的充值记录导出 |
|
|
|
form.startTime = moment(form.start_time).format("YYYY-MM-DD HH:mm:ss"); |
|
|
|
form.endTime = moment(form.end_time).format("YYYY-MM-DD HH:mm:ss"); |
|
|
|
if (form.time) { |
|
|
|
form = { |
|
|
|
...form, |
|
|
|
time: moment(form.time).format('YYYY-MM-DD') |
|
|
|
} |
|
|
|
} |
|
|
|
if (exportUrl == "/api/fin/order_search/arrears_order_update_list_export") { //特殊情况,财务管理-停车订单查询-订单修改记录 |
|
|
|
form.deal_time_end = moment(form.deal_time_end).format("YYYY-MM-DD HH:mm:ss"); |
|
|
|
form.deal_time_start = moment(form.deal_time_start).format("YYYY-MM-DD HH:mm:ss"); |
|
|
|
if (areaName !== null) form[areaName] = areaSelectedList; |
|
|
|
if (form.start_time !== void 0 && form.end_time !== void 0) { |
|
|
|
form.start_time = moment(form.start_time).format("YYYY-MM-DD HH:mm:ss"); |
|
|
|
form.end_time = moment(form.end_time).format("YYYY-MM-DD HH:mm:ss"); |
|
|
|
if (exportUrl == "/api/ope/record/recharge_export") { //特殊情况,用户信息的充值记录导出 |
|
|
|
form.startTime = moment(form.start_time).format("YYYY-MM-DD HH:mm:ss"); |
|
|
|
form.endTime = moment(form.end_time).format("YYYY-MM-DD HH:mm:ss"); |
|
|
|
} |
|
|
|
if (exportUrl == "/api/fin/order_search/arrears_order_update_list_export") { //特殊情况,财务管理-停车订单查询-订单修改记录 |
|
|
|
form.deal_time_end = moment(form.deal_time_end).format("YYYY-MM-DD HH:mm:ss"); |
|
|
|
form.deal_time_start = moment(form.deal_time_start).format("YYYY-MM-DD HH:mm:ss"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (exportUrl == "/api/fin/order_search/parking_card_order_list" || exportUrl == "/api/fin/order_search/staggered_parking_order_list") { //特殊情况,商品订单查询导出 |
|
|
|
form = { |
|
|
|
...form, |
|
|
|
export: 1, |
|
|
|
export_file_name: filename, |
|
|
|
if (exportUrl == "/api/fin/order_search/parking_card_order_list" || exportUrl == "/api/fin/order_search/staggered_parking_order_list") { //特殊情况,商品订单查询导出 |
|
|
|
form = { |
|
|
|
...form, |
|
|
|
export: 1, |
|
|
|
export_file_name: filename, |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (tableData.length != 0) { |
|
|
|
exportAjax({ |
|
|
|
url: exportUrl, |
|
|
|
type: "post", |
|
|
|
data: { ...form, ...export_other }, |
|
|
|
}) |
|
|
|
.then((res) => { |
|
|
|
if (res.status === 20000) { |
|
|
|
const link = document.createElement("a"); |
|
|
|
link.href = res.data.url || res.data.export_url; |
|
|
|
link.target = "_blank"; // 打开新页面 |
|
|
|
link.click(); |
|
|
|
setTipModal({ |
|
|
|
...tipModal, visible: false, |
|
|
|
filename: |
|
|
|
pagename + |
|
|
|
(new Date().getMonth() + 1).toString().padStart(2, "0") + |
|
|
|
new Date().getDate(), |
|
|
|
}); |
|
|
|
tipForm.setFieldsValue({ filename: pagename + (new Date().getMonth() + 1).toString().padStart(2, "0") + new Date().getDate(), }) |
|
|
|
} else { |
|
|
|
message.error(res.message); |
|
|
|
} |
|
|
|
if (tableData.length != 0) { |
|
|
|
exportAjax({ |
|
|
|
url: exportUrl, |
|
|
|
type: "post", |
|
|
|
data: { ...form, ...export_other }, |
|
|
|
}) |
|
|
|
.catch((err) => { |
|
|
|
console.error(err); |
|
|
|
}); |
|
|
|
} else { |
|
|
|
message.error('该页面无数据,无法导出') |
|
|
|
} |
|
|
|
.then((res) => { |
|
|
|
if (res.status === 20000) { |
|
|
|
const link = document.createElement("a"); |
|
|
|
link.href = res.data.url || res.data.export_url; |
|
|
|
link.target = "_blank"; // 打开新页面 |
|
|
|
link.click(); |
|
|
|
setTipModal({ |
|
|
|
...tipModal, visible: false, |
|
|
|
filename: |
|
|
|
pagename + |
|
|
|
(new Date().getMonth() + 1).toString().padStart(2, "0") + |
|
|
|
new Date().getDate(), |
|
|
|
}); |
|
|
|
tipForm.setFieldsValue({ filename: pagename + (new Date().getMonth() + 1).toString().padStart(2, "0") + new Date().getDate(), }) |
|
|
|
resolved() |
|
|
|
} else { |
|
|
|
message.error(res.message); |
|
|
|
rejected(res.message) |
|
|
|
} |
|
|
|
}) |
|
|
|
.catch((err) => { |
|
|
|
console.error(err); |
|
|
|
rejected(err) |
|
|
|
}); |
|
|
|
} else { |
|
|
|
message.error('该页面无数据,无法导出') |
|
|
|
rejected('该页面无数据,无法导出') |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
}; |
|
|
|
function handleOk() { |
|
|
@ -932,6 +942,14 @@ const TableModule = forwardRef((props, ref) => { |
|
|
|
fetch, |
|
|
|
})); |
|
|
|
|
|
|
|
const handleExport = (start, end) => { |
|
|
|
exportBtn(pagename + (new Date().getMonth() + 1).toString().padStart(2, "0") + new Date().getDate(), start, end).then(() => { |
|
|
|
exportRef.current.handleCancel() |
|
|
|
}).catch(msg => { |
|
|
|
exportRef.current.handleError() |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
fetch(); |
|
|
@ -1002,12 +1020,27 @@ const TableModule = forwardRef((props, ref) => { |
|
|
|
{rightButtonGroup.map((item) => item)} |
|
|
|
{diyButton ? diyButton : null} |
|
|
|
{isExport && ( |
|
|
|
<Button |
|
|
|
type="primary" |
|
|
|
onClick={() => setTipModal({ ...tipModal, visible: true })} |
|
|
|
> |
|
|
|
导出 |
|
|
|
</Button> |
|
|
|
// <Button |
|
|
|
// type="primary" |
|
|
|
// onClick={() => setTipModal({ ...tipModal, visible: true })} |
|
|
|
// > |
|
|
|
// 导出 |
|
|
|
// </Button> |
|
|
|
total ? ( |
|
|
|
<ExportBtnNew |
|
|
|
children={<Button className="export-btn" size='medium' type="primary">导出</Button>} |
|
|
|
modalType="noImg" |
|
|
|
ref={exportRef} |
|
|
|
totalRecords={total} |
|
|
|
exportUrl={exportUrl} |
|
|
|
imgno={false} |
|
|
|
postdata={{ |
|
|
|
formData: pageData |
|
|
|
}} |
|
|
|
isTableModule={true} |
|
|
|
onOk={handleExport} |
|
|
|
/> |
|
|
|
) : <></> |
|
|
|
)} |
|
|
|
</div> |
|
|
|
</div> |
|
|
|