This commit is contained in:
Richie 2025-05-31 20:56:02 +08:00
parent 9060f76d71
commit d232926858
2 changed files with 67 additions and 81 deletions

View File

@ -0,0 +1,64 @@
package cn.qihangerp.api.pdd.controller;
import cn.qihangerp.common.AjaxResult;
import cn.qihangerp.open.dou.DouRequest;
import cn.qihangerp.security.common.BaseController;
import lombok.AllArgsConstructor;
import lombok.extern.java.Log;
import org.springframework.web.bind.annotation.*;
@Log
@AllArgsConstructor
@RestController
@RequestMapping("/pdd/ewaybill")
public class PddWaybillController extends BaseController {
@GetMapping(value = "/get_waybill_account_list")
public AjaxResult getWaybillAccountList(Long shopId) throws Exception {
return AjaxResult.error("开源版本不支持电子面单功能");
}
/**
* 拉取电子面单账号
*
* @param params
* @return
* @throws Exception
*/
@RequestMapping(value = "/pull_waybill_account", method = RequestMethod.POST)
public AjaxResult pullWaybillAccount(@RequestBody DouRequest params) throws Exception {
return AjaxResult.error("开源版本不支持电子面单功能");
}
@PostMapping("/get_waybill_code")
@ResponseBody
public AjaxResult getWaybillCode() {
return AjaxResult.error("开源版本不支持电子面单功能");
}
@PostMapping("/get_print_data")
@ResponseBody
public AjaxResult getPrintData() {
return AjaxResult.error("开源版本不支持电子面单功能");
}
@PostMapping("/push_print_success")
@ResponseBody
public AjaxResult pushPrintSuccess() {
return AjaxResult.error("开源版本不支持电子面单功能");
}
/**
* 发货
*
* @param
* @return
*/
@PostMapping("/push_ship_send")
@ResponseBody
public AjaxResult pushShipSend() {
return AjaxResult.error("开源版本不支持电子面单功能");
}
}

View File

@ -287,31 +287,7 @@ export default {
this.multiple = !selection.length this.multiple = !selection.length
}, },
openWs() { openWs() {
const ws = new WebSocket('ws://127.0.0.1:5000'); this.$modal.msgError("开源版本未实现电子面单相关功能!请自行对接发货");
ws.onopen = () => {
console.log('与打印组件建立连接成功: ');
//
ws.send(JSON.stringify({
requestID: '1234554',
cmd: 'getPrinters',
"version": "1.0"
}))
};
let obj = this.$modal;
ws.onmessage = (e) => {
const resp = JSON.parse(e.data || '{}')
if (resp.cmd === 'getPrinters') {
this.printerList = resp.printers
obj.msgSuccess("打印组件连接成功!");
console.log('打印机列表: ', resp.printers);
}
};
//
ws.onerror = function (error) {
obj.msgError("打印组件连接失败!请安装并启动拼多多打印组件!");
console.error('WebSocket error:', error);
// alert('WebSocket error occurred. Check the console for more details.');
};
}, },
// //
handleGetEwaybillCode() { handleGetEwaybillCode() {
@ -355,67 +331,13 @@ export default {
}); });
}, },
handlePrintEwaybill() { handlePrintEwaybill() {
// if (!this.ws) {
// this.$modal.msgError('');
// this.openWs()
// }
// if(!this.printParams.deliver){
// this.$modal.msgError('');
// return
// }
if (!this.printParams.printer) { if (!this.printParams.printer) {
this.$modal.msgError('请选择打印机!'); this.$modal.msgError('请选择打印机!');
return return
} }
const ids = this.ids;
getWaybillPrintData({shopId: this.queryParams.shopId, ids: ids}).then(response => {
console.log("======打印======", response.data)
if (response.data) {
const ws = new WebSocket('ws://127.0.0.1:5000');
ws.onopen = () => {
let printData = []
response.data.forEach(x => printData.push(JSON.parse(x.printData)))
console.log('开始打印: 组合打印数据:', printData);
//
ws.send(JSON.stringify({
"cmd": "print",
"requestID": this.getUUID(8, 16),
"version": "1.0",
"task": {
"taskID": this.getUUID(8,10),
"preview": false,
"printer": this.printParams.printer,
"previewType": "pdf",
"firstDocumentNumber": 10,
"totalDocumentCount": 100,
"documents": [{
"documentID": this.getUUID(8,10),
"contents": printData
}]
}
}))
};
let obj = this.$modal;
ws.onmessage = (e) => {
const resp = JSON.parse(e.data || '{}')
if (resp.cmd === 'print') {
console.log('打印结果: ', resp);
obj.msgSuccess("打印成功!" + JSON.stringify(resp));
//
return pushWaybillPrintSuccess({shopId: this.queryParams.shopId, ids: ids})
}
};
//
ws.onerror = function (error) {
obj.msgError("打印失败!");
console.error('WebSocket error:', error);
// alert('WebSocket error occurred. Check the console for more details.');
};
}
});
this.$modal.msgError("开源版本未实现电子面单相关功能!请自行对接发货");
}, },
handleShipSend(){ handleShipSend(){