@@ -613,17 +489,18 @@ export default {
},
data() {
return {
- typeList:[],
- showPrices:false,
- printHiddenFlag:false,//隐藏信息
- printInfoObj:{
+ typeList: [],
+ showPrices: false,
+ printHiddenFlag: false,//隐藏信息
+ printInfoObj: {
id: "printInfo",//要打印的id名 无#号
- popTitle:' ',//页眉标题 默认浏览器标题 空字符串时显示undefined 使用html语言
- extraHead:'',//头部文字 默认空
+ popTitle: ' ',//页眉标题 默认浏览器标题 空字符串时显示undefined 使用html语言
+ extraHead: '',//头部文字 默认空
},
submitLoading: false, // 添加或编辑提交状态
region: [], //地区
regionId: [], //地区id
+ logisticsType: 'KUAIDINIAO', //物流类型
showRegion: false,
someJSONdata: '',
faceSheetForm: {
@@ -631,7 +508,7 @@ export default {
},
faceSheetFormValidate: {
logisticsId: [
- { required: true, message: "请选择物流公司"},
+ { required: true, message: "请选择物流公司" },
],
},
facesheetFlag: false, //电子面单标识
@@ -652,7 +529,7 @@ export default {
},
},
modal: false, //弹出调整价格框
- printModal:false,//弹出打印发货单
+ printModal: false,//弹出打印发货单
//调整价格表单
modifyPriceForm: {
orderPrice: 0,
@@ -826,13 +703,13 @@ export default {
this.orderTakeModal = true;
},
//打印发货单
- printOrder(){
+ printOrder() {
this.printModal = true;
},
- printHiddenInfo(){
+ printHiddenInfo() {
this.printHiddenFlag = !this.printHiddenFlag;
},
- printCancel(){
+ printCancel() {
// this.printHiddenFlag = false;
},
//订单核销提交
@@ -851,28 +728,28 @@ export default {
}
});
},
- getOrderPrice(){
- if(this.showPrices){
+ getOrderPrice() {
+ if (this.showPrices) {
this.showPrices = false
- }else if(!this.showPrices){
+ } else if (!this.showPrices) {
this.showPrices = true
}
},
- getContentPrice(){
- for (let i = 0; i < this.typeList.length; i++) {
- for (let j = i + 1; j < this.typeList.length; j++) {
- if (this.typeList[i].promotionId === this.typeList[j].promotionId) {
- this.typeList[i].discountPrice = this.typeList[i].discountPrice + this.typeList[j].discountPrice
- this.typeList.splice(j, 1)
- }
+ getContentPrice() {
+ for (let i = 0; i < this.typeList.length; i++) {
+ for (let j = i + 1; j < this.typeList.length; j++) {
+ if (this.typeList[i].promotionId === this.typeList[j].promotionId) {
+ this.typeList[i].discountPrice = this.typeList[i].discountPrice + this.typeList[j].discountPrice
+ this.typeList.splice(j, 1)
}
}
- console.log(this.typeList)
- if(this.typeList.length >= 3){
- console.log(123123)
- this.getContentPrice()
- }
- },
+ }
+ console.log(this.typeList)
+ if (this.typeList.length >= 3) {
+ console.log(123123)
+ this.getContentPrice()
+ }
+ },
//获取订单详细信息
getDataDetail() {
this.loading = true;
@@ -889,7 +766,7 @@ export default {
}
});
},
- Toprint(){
+ Toprint() {
this.facesheetFlag = true;
API_Logistics.getCheckedOn().then(res => {
if (res.success) {
@@ -937,35 +814,83 @@ export default {
//订单发货
orderDeliver() {
this.facesheetFlag = false
- API_Order.getLogisticsChecked().then((res) => {
- if (res.success) {
- this.checkedLogistics = res.result;
- this.orderDeliverModal = true;
- }
- });
+ if (this.logisticsType == 'SHUNFENG') {
+ this.$Modal.confirm({
+ title: "确认发货",
+ content: "您确认使用顺丰发货 " + this.sn + " 订单?",
+ loading: true,
+ onOk: () => {
+ API_Order.orderShunFengDelivery(this.sn).then((res) => {
+ if (res.success) {
+ this.$Modal.remove();
+ this.$Message.success("订单发货成功");
+ this.getDataDetail()
+ }
+ })
+ }
+ })
+ } else {
+ API_Order.getLogisticsChecked().then((res) => {
+ if (res.success) {
+ this.checkedLogistics = res.result;
+ this.orderDeliverModal = true;
+ }
+ });
+ }
},
- Toprints(){
- if(this.form.logisticsId != null && this.form.logisticsId != ''){
+ //顺丰打印面单
+ sfPrint() {
+ API_Order.getOrderFaceSheet(this.sn, this.faceSheetForm).then(res => {
+ if (res.success) {
+ let headers = {
+ 'X-Auth-token': res.result.token
+ }
+ API_Logistics.getShunFengFaceSheet(res.result.url, headers).then(res => {
+ const blob = new Blob([res], {
+ type: "application/pdf;charset=utf-8",
+ });
+ console.log("出发blob");
+ //对于
标签,只有 Firefox 和 Chrome(内核) 支持 download 属性
+ //IE10以上支持blob但是依然不支持download
+ if ("download" in document.createElement("a")) {
+ //支持a标签download的浏览器
+ const link = document.createElement("a"); //创建a标签
+ link.download = this.orderInfo.order.sn + ".pdf"; //a标签添加属性
+ link.style.display = "none";
+ link.href = URL.createObjectURL(blob);
+ document.body.appendChild(link);
+ link.click(); //执行下载
+ URL.revokeObjectURL(link.href); //释放url
+ document.body.removeChild(link); //释放标签
+ } else {
+ navigator.msSaveBlob(blob, fileName);
+ }
+ })
+ }
+ })
+ },
+ Toprints() {
+ if (this.form.logisticsId != null && this.form.logisticsId != '') {
this.orderDeliverModal = false;
}
},
//订单发货提交
orderDeliverySubmit() {
- if(this.facesheetFlag){
+ if (this.facesheetFlag) {
this.$refs['faceSheetForm'].validate((valid) => {
if (valid) {
API_Order.getOrderFaceSheet(this.sn, this.faceSheetForm).then(res => {
if (res.success) {
- this.someJSONdata = res.result;
+ this.someJSONdata = res.result.printTemplate;
this.Toprints();
}
})
}
})
- }else{
+ } else {
this.$refs['orderDeliveryForm'].validate((valid) => {
if (valid) {
- API_Order.orderDelivery(this.sn,this.orderDeliveryForm).then(
+ API_Order.orderDelivery(this.sn, this.orderDeliveryForm).then(
(res) => {
if (res.success) {
this.$Message.success("订单发货成功");
@@ -1014,14 +939,24 @@ export default {
}
});
},
+
+ getLogisticsSetting() {
+ API_Logistics.getLogisticsSetting().then(res => {
+ if (res.success) {
+ this.logisticsType = res.result;
+ }
+ })
+ },
+
},
mounted() {
this.sn = this.$route.query.sn;
this.getDataDetail();
+ this.getLogisticsSetting();
},
// 如果是从详情页返回列表页,修改列表页keepAlive为true,确保不刷新页面
- beforeRouteLeave(to, from, next){
- if(to.name === 'orderList' || to.name === 'virtualOrderList') {
+ beforeRouteLeave(to, from, next) {
+ if (to.name === 'orderList' || to.name === 'virtualOrderList') {
to.meta.keepAlive = true
}
next()
@@ -1031,9 +966,10 @@ export default {