From d1898a1917d554b6161cc728bdfc7aef34be26b0 Mon Sep 17 00:00:00 2001 From: zhangds Date: Mon, 26 Feb 2024 11:02:40 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E7=B3=BB=E7=BB=9F=E5=8C=85=E7=A0=81=E7=BB=93?= =?UTF-8?q?=E7=AE=97=E5=88=97=E8=A1=A8=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/assets/api.js | 7 +++ src/pages/order/settlementList/list.jsx | 73 ++++++++++++++++++++++--- 2 files changed, 73 insertions(+), 7 deletions(-) diff --git a/src/assets/api.js b/src/assets/api.js index f8ed70ce..d2fcbdcb 100644 --- a/src/assets/api.js +++ b/src/assets/api.js @@ -1038,4 +1038,11 @@ export const getPackageDetail = (id) => { return req("get", baseurl + "/settlement_order/detail/" + id) } +/** + * 包码订单导出 + */ +export const getSettlementListOrderExport = (params) => { + return derive("get", baseurl + "/settlement_order/export", params) +} + export { req } diff --git a/src/pages/order/settlementList/list.jsx b/src/pages/order/settlementList/list.jsx index 8c8d314c..0a26b0d1 100644 --- a/src/pages/order/settlementList/list.jsx +++ b/src/pages/order/settlementList/list.jsx @@ -4,7 +4,8 @@ import { getSettlementOrder, getSettlementType, handelResponse, - queryKeyBatch + queryKeyBatch, + getSettlementListOrderExport } from "@/assets/api.js" import "@/assets/comm.css" import { nowDay, nowMonth } from "@/assets/comm.js" @@ -14,10 +15,11 @@ import Grid from "@/components/gird/main.js" import Ipt from "@/components/input/main" import TabPage from "@/components/tabPage/main.js" import React from "react" -import { Alert, Button, CombinedDateRangePicker, Notify, Select } from "zent" +import { Alert, Button, CombinedDateRangePicker, Notify, Select, Sweetalert } from "zent" import "./list.less" import { Column } from "./utils" import { pickBy } from "lodash-es" +import { getNowTime } from "@/tools/utils.js" var moment = require("moment") let day = moment(nowDay()).format("YYYY-MM-DD") @@ -168,6 +170,55 @@ export default class settlementList extends React.Component { }) } + /** + * 导出 + */ + bachExportOrder() { + let { page, limit, search, combinedValue } = this.state + let { key, key_batch_id, plan_id, reseller_id, type } = search + + // 导出必须有时间和计划id + if (!plan_id || !combinedValue) { + Notify.error("订单导出必须有计划id和时间") + return + } + + let params = { + page, + limit, + begin_time: combinedValue[0], + end_time: combinedValue[1], + key: key ? key : "", + key_batch_id: key_batch_id ? key_batch_id.key : "", + plan_id: plan_id ? plan_id.key : "", + reseller_id: reseller_id ? reseller_id.key : "", + type: type ? type.key : "" + } + try { + getSettlementListOrderExport(params).then((res) => { + if (res.type == "application/json") { + const reader = new FileReader() //创建一个FileReader实例 + reader.readAsText(res, "utf-8") //读取文件,结果用字符串形式表示 + reader.onload = function () { + const obj = JSON.parse(reader.result) + Notify.clear() + Notify.error(obj.message) + } + } else { + let bl = new Blob([res]) + let fileName = "包码结算订单列表" + getNowTime() + ".xlsx" //设置文件名 + var link = document.createElement("a") //创建标签 + link.href = window.URL.createObjectURL(bl) + link.download = fileName //下载的文件名 + link.click() + window.URL.revokeObjectURL(link.href) //清除URL + } + }) + } catch (e) { + console.log(e) + } + } + //page pageChange(e) { this.setState({ selectionData: [], page: e }, () => { @@ -321,7 +372,7 @@ export default class settlementList extends React.Component { /> -
+
+
- {this.state.selectionData.length > 0 ? ( + {/* {this.state.selectionData.length > 0 ? ( - ) : null} + ) : null} */} { this.countChange(e) }} - checkChange={this.selection.bind(this)} + // checkChange={this.selection.bind(this)} ComponentHandler={(com, rowData) => { if (com == "opearo") { return (