From 1c3933b20438da1d858dda2161f058dfa1b36f1e Mon Sep 17 00:00:00 2001
From: ZZJ <10913410+zzj2100@user.noreply.gitee.com>
Date: 星期三, 22 六月 2022 15:01:29 +0800
Subject: [PATCH] 联动场景新增算法
---
src/views/personalCenter/components/OrderMng.vue | 183 ++++++++++++++++++++++++++++-----------------
1 files changed, 115 insertions(+), 68 deletions(-)
diff --git a/src/views/personalCenter/components/OrderMng.vue b/src/views/personalCenter/components/OrderMng.vue
index 9e9f084..289ad15 100644
--- a/src/views/personalCenter/components/OrderMng.vue
+++ b/src/views/personalCenter/components/OrderMng.vue
@@ -26,7 +26,7 @@
<div class="button searchBtn" @click="searchingBtn">鎼滅储</div>
<div class="button resetBtn" @click="clearSearch">閲嶇疆</div>
</div>
- <div class="to-excel">
+ <div class="to-excel" @click="exportList">
<span class="iconfont"></span> <span>瀵煎嚭</span>
</div>
</div>
@@ -237,7 +237,7 @@
</template>
<script>
-import { getOrders } from "@/api/order";
+import { getOrders, getAuthFile } from "@/api/order";
import { getOrderById } from "@/api/product";
export default {
@@ -285,82 +285,86 @@
let param = {
page: this.page,
size: this.size,
- startTime: this.searchTime[0],
- endTime: this.searchTime[1],
+ startTime: this.searchTime ? this.searchTime[0] : "",
+ endTime: this.searchTime ? this.searchTime[1] : "",
inputText: this.inputText,
productBaseId: "0",
orderName: "",
orderType: "",
status: 0,
};
- getOrders(param).then((res) => {
- this.dataList = res.data.list.map((item, indez) => {
- let status = "";
- switch (item.orderStatus) {
- case -1:
- status = "宸插彇娑�";
- break;
- case 0:
- status = "鏈笅鍗�";
- break;
- case 1:
- status = "寰呮敮浠�";
- break;
- case 2:
- status = "宸叉敮浠�";
- break;
- case 11:
- status = "瀹℃牳涓�";
- break;
- case 12:
- status = "宸查┏鍥�";
- break;
- default:
- status = "";
- }
- let name = "";
- let downFlag = false;
- let products = [];
- item.products.forEach((every, index) => {
- // 鍒ゆ柇鏈鍗曟槸鍚﹀瓨鍦ㄥ彲涓嬭浇鐨勫唴瀹癸紙杞欢锛宻dk锛�
- if (every.productType == 1 || every.productType == 3) {
- downFlag = true;
+ getOrders(param)
+ .then((res) => {
+ this.dataList = res.data.list.map((item, indez) => {
+ let status = "";
+ switch (item.orderStatus) {
+ case -1:
+ status = "宸插彇娑�";
+ break;
+ case 0:
+ status = "鏈笅鍗�";
+ break;
+ case 1:
+ status = "寰呮敮浠�";
+ break;
+ case 2:
+ status = "宸叉敮浠�";
+ break;
+ case 11:
+ status = "瀹℃牳涓�";
+ break;
+ case 12:
+ status = "宸查┏鍥�";
+ break;
+ default:
+ status = "";
}
- // 褰掔被浜у搧鍜屾縺娲荤爜浠ヤ緵涓嬭浇
- products.push({
- productId: every.productId,
- productName: every.productName,
- activateCode: every.activateCode,
- productTypeName: every.productTypeName,
+ let name = "";
+ let downFlag = false;
+ let products = [];
+ item.products.forEach((every, index) => {
+ // 鍒ゆ柇鏈鍗曟槸鍚﹀瓨鍦ㄥ彲涓嬭浇鐨勫唴瀹癸紙杞欢锛宻dk锛�
+ if (every.productType == 1 || every.productType == 3) {
+ downFlag = true;
+ }
+ // 褰掔被浜у搧鍜屾縺娲荤爜浠ヤ緵涓嬭浇
+ products.push({
+ productId: every.productId,
+ productName: every.productName,
+ activateCode: every.activateCode,
+ productTypeName: every.productTypeName,
+ });
+ if (index == 0) {
+ name += every.productName + "(" + every.productTypeName + ")";
+ } else {
+ name +=
+ " / " + every.productName + "(" + every.productTypeName + ")";
+ }
});
- if (index == 0) {
- name += every.productName + "(" + every.productTypeName + ")";
- } else {
- name +=
- " / " + every.productName + "(" + every.productTypeName + ")";
- }
+ return {
+ id: item.id,
+ sn: item.sn,
+ name: name,
+ source: item.source == 0 ? "婵�娲荤爜涓嬭浇" : "绾夸笂璐拱",
+ createTime: item.createTime,
+ status: status,
+ orderStatus: item.orderStatus,
+ orderMoney: item.orderMoney,
+ payMethod: item.payMethod,
+ code:
+ item.products.length > 1 ? "-" : item.products[0].activateCode,
+ canDownLoad: downFlag,
+ products: products,
+ };
});
- return {
- id: item.id,
- sn: item.sn,
- name: name,
- source: item.source == 0 ? "婵�娲荤爜涓嬭浇" : "绾夸笂璐拱",
- createTime: item.createTime,
- status: status,
- orderStatus: item.orderStatus,
- orderMoney: item.orderMoney,
- payMethod: item.payMethod,
- code:
- item.products.length > 1 ? "-" : item.products[0].activateCode,
- canDownLoad: downFlag,
- products: products,
- };
+ this.total = res.data.total;
+ if (res.data.total <= this.size) {
+ this.page = 1;
+ }
+ })
+ .catch((err) => {
+ this.$notify.error(err.msg);
});
- this.total = res.data.total;
- if (res.data.total <= this.size) {
- this.page = 1;
- }
- });
},
//鍒嗛〉鍔熻兘
handleSizeChange(size) {
@@ -392,7 +396,9 @@
},
clearSearch() {
+ debugger;
this.searchTime = this.getDateInit();
+ debugger;
this.inputText = "";
this.searchingBtn();
},
@@ -505,6 +511,46 @@
openImg(url) {
window.open("http://" + url);
},
+
+ async exportList() {
+ let param = {
+ page: this.page,
+ size: this.size,
+ startTime: this.searchTime ? this.searchTime[0] : "",
+ endTime: this.searchTime ? this.searchTime[1] : "",
+ inputText: this.inputText,
+ productBaseId: "0",
+ orderName: "",
+ orderType: "",
+ status: 0,
+ };
+
+ const result = await getAuthFile(param);
+
+ console.log(result);
+
+ var blob = new Blob([result.body.data], {
+ type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8",
+ }),
+ Temp = document.createElement("a");
+
+ Temp.href = window.URL.createObjectURL(blob);
+
+ console.log(result);
+ console.log(result.fileName);
+
+ Temp.download = window.decodeURI(result.fileName);
+
+ Temp.setAttribute("download", result.fileName);
+
+ document.body.appendChild(Temp);
+
+ Temp.click();
+
+ document.body.removeChild(Temp);
+
+ window.URL.revokeObjectURL(Temp);
+ },
},
mounted() {},
};
@@ -557,6 +603,7 @@
align-items: center;
justify-content: center;
margin-left: 195px;
+ cursor: pointer;
}
.resetBtn {
width: 60px;
--
Gitblit v1.8.0