mirror of
https://gitee.com/hzchunfen/erp.git
synced 2025-11-30 22:20:45 +00:00
feat: #10000 打印完成
This commit is contained in:
parent
2ed22b91b5
commit
b3f2537768
@ -154,6 +154,7 @@ class BusinessOrderController extends Controller
|
|||||||
->where('plat_id', Shop::$PLAT_KTT)
|
->where('plat_id', Shop::$PLAT_KTT)
|
||||||
->pluck('id');
|
->pluck('id');
|
||||||
$builder = BusinessOrder::query()
|
$builder = BusinessOrder::query()
|
||||||
|
->where('order_sn', 'PO-230728-287005797932723')
|
||||||
->with('items')
|
->with('items')
|
||||||
->whereIn('shop_id', $shopIds)
|
->whereIn('shop_id', $shopIds)
|
||||||
->filter();
|
->filter();
|
||||||
@ -168,14 +169,59 @@ class BusinessOrderController extends Controller
|
|||||||
$contents = $waybill->getContents();
|
$contents = $waybill->getContents();
|
||||||
// 待打印数据
|
// 待打印数据
|
||||||
[$documents, $orderIds] = $waybill->getDocumentsAndOrderIds($contents);
|
[$documents, $orderIds] = $waybill->getDocumentsAndOrderIds($contents);
|
||||||
// 只有订单商品种类2-5的需要配货单
|
|
||||||
if (2 !== $request->get('goods_sku_num')) {
|
|
||||||
$orderIds = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
return response([
|
return response([
|
||||||
'documents' => $documents,
|
'documents' => $this->combinationPrintDocuments($documents),
|
||||||
'order_ids' => $orderIds,
|
'order_ids' => implode(',', $orderIds),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function combinationPrintDocuments($documents)
|
||||||
|
{
|
||||||
|
$documentData = [
|
||||||
|
'data' => [
|
||||||
|
'height' => 240,
|
||||||
|
'list' => [
|
||||||
|
[
|
||||||
|
'fontSize' => 31.2,
|
||||||
|
'height' => 45.68,
|
||||||
|
'left' => 2.08,
|
||||||
|
'text' => '', // 备注
|
||||||
|
'top' => 2.08,
|
||||||
|
'width' => 413.52
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'waterdata' => [
|
||||||
|
'text' => ''
|
||||||
|
],
|
||||||
|
'width' => 560
|
||||||
|
],
|
||||||
|
'templateURL' => 'http://pinduoduoimg.yangkeduo.com/logistics/2019-07-14/5d7e8b5969d954539fcfba3268bbeb3a.xml'
|
||||||
|
];
|
||||||
|
$data = [];
|
||||||
|
foreach ($documents as &$document) {
|
||||||
|
$documentID = $document['documentID'];
|
||||||
|
unset($document['documentID']);
|
||||||
|
$data[] = [
|
||||||
|
'documentID' => $documentID,
|
||||||
|
'contents' => [
|
||||||
|
$document,
|
||||||
|
$documentData
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function printSuccess(Request $request)
|
||||||
|
{
|
||||||
|
$orderIds = $request->input('order_ids');
|
||||||
|
$orderIds = explode(',', $orderIds);
|
||||||
|
BusinessOrder::query()
|
||||||
|
->where('id', $orderIds)
|
||||||
|
->increment('print_status');
|
||||||
|
|
||||||
|
return response(['message' => 'success']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,6 +15,7 @@ class WayBillService
|
|||||||
|
|
||||||
public function getContents()
|
public function getContents()
|
||||||
{
|
{
|
||||||
|
// 已下单过的订单不再下单
|
||||||
$contents = [];
|
$contents = [];
|
||||||
foreach ($this->orders as $shopId => $order) {
|
foreach ($this->orders as $shopId => $order) {
|
||||||
// 花落测试;
|
// 花落测试;
|
||||||
@ -28,33 +29,47 @@ class WayBillService
|
|||||||
foreach ($order as $item) {
|
foreach ($order as $item) {
|
||||||
[$sender, $orderInfo, $wpCode] = $this->prepareRequest($item, $shop);
|
[$sender, $orderInfo, $wpCode] = $this->prepareRequest($item, $shop);
|
||||||
$waybill = $this->saveWayBill($item, $shop);
|
$waybill = $this->saveWayBill($item, $shop);
|
||||||
$resp = $faceSheet->getWayBill($sender, $orderInfo, $wpCode);
|
if (empty($waybill->id)) {
|
||||||
if (isset($resp['pdd_waybill_get_response'])) {
|
$resp = $faceSheet->getWayBill($sender, $orderInfo, $wpCode);
|
||||||
$data = $resp['pdd_waybill_get_response']['modules'][0];
|
if (isset($resp['pdd_waybill_get_response'])) {
|
||||||
$printData = json_decode($data['print_data'], true);
|
$data = $resp['pdd_waybill_get_response']['modules'][0];
|
||||||
$waybill->request_id = $resp['pdd_waybill_get_response']['request_id'];
|
$printData = json_decode($data['print_data'], true);
|
||||||
$waybill->encryptedData = $printData['encryptedData'];
|
$waybill->request_id = $resp['pdd_waybill_get_response']['request_id'];
|
||||||
$waybill->signature = $printData['signature'];
|
$waybill->encryptedData = $printData['encryptedData'];
|
||||||
$waybill->templateUrl = $printData['templateUrl'];
|
$waybill->signature = $printData['signature'];
|
||||||
$waybill->ver = $printData['ver'];
|
$waybill->templateUrl = $printData['templateUrl'];
|
||||||
$waybill->waybill_code = $data['waybill_code'];
|
$waybill->ver = $printData['ver'];
|
||||||
$waybill->save();
|
$waybill->waybill_code = $data['waybill_code'];
|
||||||
// 返回待打印内容
|
$waybill->save();
|
||||||
|
// 返回待打印内容
|
||||||
|
$contents[$waybill->id] = [
|
||||||
|
'addData' => [
|
||||||
|
'sender' => $sender,
|
||||||
|
],
|
||||||
|
'encryptedData' => $printData['encryptedData'],
|
||||||
|
'signature' => $printData['signature'],
|
||||||
|
'templateUrl' => 'http://pinduoduoimg.yangkeduo.com/print_template/2019-08-01/4f0d85f35ca5729ad7df47314c990c31.xml',
|
||||||
|
'ver' => $printData['ver'],
|
||||||
|
'userid' => $waybill->user_id,
|
||||||
|
'items' => $item['items'],
|
||||||
|
'documentID' => $waybill->id,
|
||||||
|
'order_id' => $item['id']
|
||||||
|
];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
$contents[$waybill->id] = [
|
$contents[$waybill->id] = [
|
||||||
'addData' => [
|
'addData' => [
|
||||||
'sender' => $sender,
|
'sender' => $sender,
|
||||||
],
|
],
|
||||||
'encryptedData' => $printData['encryptedData'],
|
'encryptedData' => $waybill->encryptedData,
|
||||||
'signature' => $printData['signature'],
|
'signature' => $waybill->signature,
|
||||||
'templateUrl' => $printData['templateUrl'],
|
'templateUrl' => 'http://pinduoduoimg.yangkeduo.com/print_template/2019-08-01/4f0d85f35ca5729ad7df47314c990c31.xml',
|
||||||
'ver' => $printData['ver'],
|
'ver' => $waybill->ver,
|
||||||
'userid' => $waybill->user_id,
|
'userid' => $waybill->user_id,
|
||||||
'items' => $item['items'],
|
'items' => json_decode($waybill->items, true),
|
||||||
'documentID' => $waybill->id,
|
'documentID' => $waybill->id,
|
||||||
'order_id' => $item['id']
|
'order_id' => $item['id']
|
||||||
];
|
];
|
||||||
|
|
||||||
return $contents; //测试
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -92,7 +107,10 @@ class WayBillService
|
|||||||
private function saveWayBill($order, $shop)
|
private function saveWayBill($order, $shop)
|
||||||
{
|
{
|
||||||
$senderConfig = $shop->senders[0];
|
$senderConfig = $shop->senders[0];
|
||||||
$waybill = new Waybill();
|
$waybill = Waybill::query()->firstOrNew(
|
||||||
|
['order_sn' => $order['order_sn']]
|
||||||
|
);
|
||||||
|
|
||||||
$waybill->shop_id = $shop->shop_id;
|
$waybill->shop_id = $shop->shop_id;
|
||||||
$waybill->object_id = $this->objectId;
|
$waybill->object_id = $this->objectId;
|
||||||
|
|
||||||
@ -114,6 +132,7 @@ class WayBillService
|
|||||||
$waybill->user_id = $shop->owner_id;
|
$waybill->user_id = $shop->owner_id;
|
||||||
$waybill->wp_code = $senderConfig['wp_code'];
|
$waybill->wp_code = $senderConfig['wp_code'];
|
||||||
$waybill->order_sn = $order['order_sn'];
|
$waybill->order_sn = $order['order_sn'];
|
||||||
|
$waybill->order_id = $order['id'];
|
||||||
$waybill->items = json_encode($order['items'], 256);
|
$waybill->items = json_encode($order['items'], 256);
|
||||||
|
|
||||||
return $waybill;
|
return $waybill;
|
||||||
@ -215,6 +234,7 @@ class WayBillService
|
|||||||
// 订单拆分组合
|
// 订单拆分组合
|
||||||
foreach ($orders as $order) {
|
foreach ($orders as $order) {
|
||||||
$info = [
|
$info = [
|
||||||
|
'id' => $order['id'],
|
||||||
'order_sn' => $order['order_sn'],
|
'order_sn' => $order['order_sn'],
|
||||||
'recipient_province' => $order['receiver_address_province'],
|
'recipient_province' => $order['receiver_address_province'],
|
||||||
'recipient_city' => $order['receiver_address_city'],
|
'recipient_city' => $order['receiver_address_city'],
|
||||||
|
|||||||
@ -49,6 +49,7 @@ class CreateWaybillsTable extends Migration
|
|||||||
$table->string('order_channels_type')->default('PDD');
|
$table->string('order_channels_type')->default('PDD');
|
||||||
|
|
||||||
$table->string('order_sn');
|
$table->string('order_sn');
|
||||||
|
$table->integer('order_id');
|
||||||
$table->text('items');
|
$table->text('items');
|
||||||
$table->tinyInteger('cancel')->default(0);
|
$table->tinyInteger('cancel')->default(0);
|
||||||
|
|
||||||
|
|||||||
20645
resources/frontend/package-lock.json
generated
20645
resources/frontend/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -14,15 +14,16 @@
|
|||||||
"nprogress": "^0.2.0",
|
"nprogress": "^0.2.0",
|
||||||
"vue": "^2.6.11",
|
"vue": "^2.6.11",
|
||||||
"vue-router": "^3.2.0",
|
"vue-router": "^3.2.0",
|
||||||
|
"vue-socket.io": "^3.0.10",
|
||||||
"vuex": "^3.4.0"
|
"vuex": "^3.4.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@vue/cli-plugin-babel": "~4.5.0",
|
"@vue/cli-plugin-babel": "^5.0.8",
|
||||||
"@vue/cli-plugin-eslint": "~4.5.0",
|
"@vue/cli-plugin-eslint": "^5.0.8",
|
||||||
"@vue/cli-plugin-router": "~4.5.0",
|
"@vue/cli-plugin-router": "^5.0.8",
|
||||||
"@vue/cli-plugin-vuex": "~4.5.0",
|
"@vue/cli-plugin-vuex": "^5.0.8",
|
||||||
"@vue/cli-service": "~4.5.0",
|
"@vue/cli-service": "^5.0.8",
|
||||||
"@vue/eslint-config-standard": "^5.1.2",
|
"@vue/eslint-config-standard": "^8.0.1",
|
||||||
"babel-eslint": "^10.1.0",
|
"babel-eslint": "^10.1.0",
|
||||||
"eslint": "^6.7.2",
|
"eslint": "^6.7.2",
|
||||||
"eslint-plugin-import": "^2.20.2",
|
"eslint-plugin-import": "^2.20.2",
|
||||||
|
|||||||
16
resources/frontend/src/api/plat.js
vendored
16
resources/frontend/src/api/plat.js
vendored
@ -54,3 +54,19 @@ export function platOrderExport(params) {
|
|||||||
params,
|
params,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function printOrders(params) {
|
||||||
|
return http({
|
||||||
|
url: "/api/print/orders",
|
||||||
|
method: "get",
|
||||||
|
params
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function printSuccess(params) {
|
||||||
|
return http({
|
||||||
|
url: "/api/print/success",
|
||||||
|
method: "put",
|
||||||
|
params
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
@ -93,7 +93,8 @@
|
|||||||
<el-button type="primary" @click="handleChoose">筛选</el-button>
|
<el-button type="primary" @click="handleChoose">筛选</el-button>
|
||||||
<el-button plain @click="handleReChoose">重置筛选</el-button>
|
<el-button plain @click="handleReChoose">重置筛选</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-button type="primary" @click="dialogVisible = true">打印</el-button>
|
<el-button type="primary" @click="print">打印</el-button>
|
||||||
|
<el-button v-if="form.goods_sku_num === 2" type="primary">配货单导出</el-button>
|
||||||
</el-form>
|
</el-form>
|
||||||
</el-card>
|
</el-card>
|
||||||
|
|
||||||
@ -142,39 +143,11 @@
|
|||||||
</el-pagination>
|
</el-pagination>
|
||||||
</div>
|
</div>
|
||||||
</el-card>
|
</el-card>
|
||||||
|
|
||||||
<!-- 配货单导出 -->
|
|
||||||
<el-dialog title="配货单导出" :visible.sync="dialogVisible" :close-on-click-modal="false">
|
|
||||||
<el-form ref="exportForm" :model="exportForm" label-width="100px" :rules="exportFormRules">
|
|
||||||
<el-form-item label="店铺:" prop="shop_id">
|
|
||||||
<el-select v-model="exportForm.shop_id" placeholder="店铺" @change="setActivity">
|
|
||||||
<el-option v-for="item in shops" :key="item.id" :label="item.name" :value="item.id">
|
|
||||||
</el-option>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="订单类型">
|
|
||||||
<el-radio-group v-model="exportForm.is_supplier">
|
|
||||||
<el-radio :label="1">自卖团订单</el-radio>
|
|
||||||
<el-radio :label="0">帮卖团订单</el-radio>
|
|
||||||
</el-radio-group>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="开始跟团号" prop="start_no">
|
|
||||||
<el-input v-model="exportForm.start_no"></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="结束跟团号" prop="end_no">
|
|
||||||
<el-input v-model="exportForm.end_no"></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item>
|
|
||||||
<el-button type="primary" @click="derivation('exportForm')">导出</el-button>
|
|
||||||
<el-button @click="dialogVisible = false">取消</el-button>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
</el-dialog>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { platOrderList, activityList } from "../../api/plat";
|
import { platOrderList, activityList, printOrders, printSuccess } from "../../api/plat";
|
||||||
import { storeList } from "../../api/shop";
|
import { storeList } from "../../api/shop";
|
||||||
import { goodsSkusList } from "../../api/goods";
|
import { goodsSkusList } from "../../api/goods";
|
||||||
export default {
|
export default {
|
||||||
@ -222,18 +195,35 @@ export default {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
confirmAt: [],
|
confirmAt: [],
|
||||||
|
print_order_ids: '',
|
||||||
|
print_documents: [],
|
||||||
|
socket: null,
|
||||||
|
lockReconnect: false, //是否真正建立连接
|
||||||
|
timeout: 58 * 1000, //58秒一次心跳
|
||||||
|
timeoutObj: null, //心跳心跳倒计时
|
||||||
|
serverTimeoutObj: null, //心跳倒计时
|
||||||
|
timeoutnum: null, //断开 重连倒计时
|
||||||
|
defaultPrinter: null,
|
||||||
|
taskIDArray: [],
|
||||||
|
requestIDGetGlobalConfig: '',
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
|
||||||
// 展示店铺列表
|
|
||||||
this.getShopsList();
|
|
||||||
},
|
|
||||||
created() {
|
created() {
|
||||||
this.initConfirmAt();
|
this.initConfirmAt();
|
||||||
this.getPlatOrderList({
|
this.getPlatOrderList({
|
||||||
confirm_at_start: this.form.confirm_at[0],
|
confirm_at_start: this.form.confirm_at[0],
|
||||||
confirm_at_end: this.form.confirm_at[1]
|
confirm_at_end: this.form.confirm_at[1]
|
||||||
});
|
});
|
||||||
|
this.initWebSocket();
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
// 展示店铺列表
|
||||||
|
this.getShopsList();
|
||||||
|
},
|
||||||
|
beforeDestroy() {
|
||||||
|
// 订阅事件记得要取消
|
||||||
|
},
|
||||||
|
destroyed() {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
initConfirmAt() {
|
initConfirmAt() {
|
||||||
@ -298,8 +288,8 @@ export default {
|
|||||||
after_sales_status: "0",
|
after_sales_status: "0",
|
||||||
// supply_participate_no: "",
|
// supply_participate_no: "",
|
||||||
// participate_no: "",
|
// participate_no: "",
|
||||||
goods_sku_num: "",
|
goods_sku_num: '',
|
||||||
print_status: "0",
|
print_status: 0,
|
||||||
external_sku_ids: [],
|
external_sku_ids: [],
|
||||||
confirm_at: this.confirmAt,
|
confirm_at: this.confirmAt,
|
||||||
};
|
};
|
||||||
@ -333,6 +323,187 @@ export default {
|
|||||||
} else {
|
} else {
|
||||||
this.options = [];
|
this.options = [];
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
print() {
|
||||||
|
const print_loading = this.$loading({
|
||||||
|
lock: true,
|
||||||
|
text: 'Loading',
|
||||||
|
spinner: 'el-icon-loading',
|
||||||
|
background: 'rgba(0, 0, 0, 0.7)'
|
||||||
|
});
|
||||||
|
printOrders(this.form).then((res) => {
|
||||||
|
this.print_documents = res.data.documents;
|
||||||
|
this.print_order_ids = res.data.order_ids;
|
||||||
|
print_loading.close();
|
||||||
|
this.doPrint();
|
||||||
|
})
|
||||||
|
},
|
||||||
|
handleSelectionChange() {
|
||||||
|
|
||||||
|
},
|
||||||
|
initWebSocket() {
|
||||||
|
//初始化weosocket
|
||||||
|
const wsuri = "ws://127.0.0.1:5000";
|
||||||
|
this.socket = new WebSocket(wsuri);
|
||||||
|
// 客户端接收服务端数据时触发
|
||||||
|
this.socket.onmessage = this.websocketonmessage;
|
||||||
|
// 连接建立时触发
|
||||||
|
this.socket.onopen = this.websocketonopen;
|
||||||
|
// 通信发生错误时触发
|
||||||
|
this.socket.onerror = this.websocketonerror;
|
||||||
|
// 连接关闭时触发
|
||||||
|
this.socket.onclose = this.websocketclose;
|
||||||
|
},
|
||||||
|
// 连接建立时触发
|
||||||
|
websocketonopen() {
|
||||||
|
//开启心跳
|
||||||
|
this.start();
|
||||||
|
if (this.socket.readyState === 1) {
|
||||||
|
// 获取打印机列表
|
||||||
|
this.getPrinters();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
start() {
|
||||||
|
//开启心跳
|
||||||
|
console.log("开启心跳");
|
||||||
|
var self = this;
|
||||||
|
self.timeoutObj && clearTimeout(self.timeoutObj);
|
||||||
|
self.serverTimeoutObj && clearTimeout(self.serverTimeoutObj);
|
||||||
|
self.timeoutObj = setTimeout(function () {
|
||||||
|
//这里发送一个心跳,后端收到后,返回一个心跳消息,
|
||||||
|
if (self.socket.readyState == 1) {
|
||||||
|
//如果连接正常
|
||||||
|
} else {
|
||||||
|
//否则重连
|
||||||
|
self.reconnect();
|
||||||
|
}
|
||||||
|
self.serverTimeoutObj = setTimeout(function () {
|
||||||
|
//超时关闭
|
||||||
|
self.socket.close();
|
||||||
|
}, self.timeout);
|
||||||
|
}, self.timeout);
|
||||||
|
},
|
||||||
|
reconnect() {
|
||||||
|
//重新连接
|
||||||
|
var that = this;
|
||||||
|
if (that.lockReconnect) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
that.lockReconnect = true;
|
||||||
|
//没连接上会一直重连,设置延迟避免请求过多
|
||||||
|
that.timeoutnum && clearTimeout(that.timeoutnum);
|
||||||
|
that.timeoutnum = setTimeout(function () {
|
||||||
|
//新连接
|
||||||
|
that.initWebSocket();
|
||||||
|
that.lockReconnect = false;
|
||||||
|
}, 5000);
|
||||||
|
},
|
||||||
|
// 通信发生错误时触发
|
||||||
|
websocketonerror() {
|
||||||
|
console.log("出现错误");
|
||||||
|
this.reconnect();
|
||||||
|
},
|
||||||
|
// 客户端接收服务端数据时触发
|
||||||
|
websocketonmessage(e) {
|
||||||
|
console.log(e);
|
||||||
|
if (JSON.parse(e.data).printers !== undefined) {
|
||||||
|
this.defaultPrinter = JSON.parse(e.data).defaultPrinter;
|
||||||
|
}
|
||||||
|
// JSON.parse 用来解析JSON字符串
|
||||||
|
console.log("默认打印机" + this.defaultPrinter)
|
||||||
|
|
||||||
|
if (JSON.parse(e.data).status === 'success') {
|
||||||
|
console.log("打印就绪..")
|
||||||
|
}
|
||||||
|
if (JSON.parse(e.data).status === 'failed') {
|
||||||
|
console.log("打印未就绪..")
|
||||||
|
}
|
||||||
|
if (JSON.parse(e.data).taskStatus === 'printed') {
|
||||||
|
console.log('出纸成功--打印成功')
|
||||||
|
// 打印成功回调
|
||||||
|
printSuccess({ order_ids: this.print_order_ids }).then((res) => {
|
||||||
|
console.log(res)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if (JSON.parse(e.data).taskStatus === 'failed') {
|
||||||
|
console.log("打印失败!")
|
||||||
|
}
|
||||||
|
if (JSON.parse(e.data).taskStatus === 'canceled') {
|
||||||
|
console.log("打印取消!")
|
||||||
|
}
|
||||||
|
|
||||||
|
//收到服务器信息,心跳重置
|
||||||
|
this.reset();
|
||||||
|
},
|
||||||
|
reset() {
|
||||||
|
//重置心跳
|
||||||
|
var that = this;
|
||||||
|
//清除时间
|
||||||
|
clearTimeout(that.timeoutObj);
|
||||||
|
clearTimeout(that.serverTimeoutObj);
|
||||||
|
//重启心跳
|
||||||
|
that.start();
|
||||||
|
},
|
||||||
|
websocketsend(Data) {
|
||||||
|
//数据发送
|
||||||
|
this.socket.send(Data);
|
||||||
|
},
|
||||||
|
// 连接关闭时触发
|
||||||
|
websocketclose(e) {
|
||||||
|
//关闭
|
||||||
|
console.log("断开连接", e);
|
||||||
|
//重连
|
||||||
|
this.reconnect();
|
||||||
|
},
|
||||||
|
getPrinters() {
|
||||||
|
var request = this.getRequestObject("getPrinters");
|
||||||
|
this.websocketsend(JSON.stringify(request));
|
||||||
|
},
|
||||||
|
doPrint() {
|
||||||
|
var request = this.getRequestObject("print");
|
||||||
|
request.task = new Object();
|
||||||
|
request.task.taskID = this.getUUID(8, 10);
|
||||||
|
// 把每次打印的任务 taskID 保存到 taskIDArray 数组
|
||||||
|
this.taskIDArray.push(request.task.taskID)
|
||||||
|
// 记录当前打印请求的ID
|
||||||
|
this.requestIDGetGlobalConfig = request.task.taskID
|
||||||
|
request.task.preview = false;
|
||||||
|
request.task.printer = this.defaultPrinter;
|
||||||
|
request.task.documents = this.print_documents;
|
||||||
|
console.log(request.task.documents)
|
||||||
|
|
||||||
|
this.websocketsend(JSON.stringify(request));
|
||||||
|
},
|
||||||
|
getRequestObject(cmd) {
|
||||||
|
var request = new Object();
|
||||||
|
// 必须:请求的ID,用于唯一标识每个请求,每个客户端保证生成唯一的ID
|
||||||
|
request.requestID = this.getUUID(8, 16);
|
||||||
|
//必须: 协议当前版本
|
||||||
|
request.version = "1.0";
|
||||||
|
//必须: 请求命令名称
|
||||||
|
request.cmd = cmd;
|
||||||
|
|
||||||
|
return request;
|
||||||
|
},
|
||||||
|
getUUID(len, radix) {
|
||||||
|
var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
|
||||||
|
var uuid = [], i;
|
||||||
|
radix = radix || chars.length;
|
||||||
|
if (len) {
|
||||||
|
for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix];
|
||||||
|
} else {
|
||||||
|
var r;
|
||||||
|
uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
|
||||||
|
uuid[14] = '4';
|
||||||
|
for (i = 0; i < 36; i++) {
|
||||||
|
if (!uuid[i]) {
|
||||||
|
r = 0 | Math.random() * 16;
|
||||||
|
uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return uuid.join('');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
4
resources/frontend/vue.config.js
vendored
4
resources/frontend/vue.config.js
vendored
@ -4,10 +4,6 @@ module.exports = {
|
|||||||
devServer: {
|
devServer: {
|
||||||
open: false, // 设置浏览器自动打开项目
|
open: false, // 设置浏览器自动打开项目
|
||||||
port: 8080, // 开发服务器运行端口号
|
port: 8080, // 开发服务器运行端口号
|
||||||
overlay: {
|
|
||||||
warnings: false,
|
|
||||||
errors: true,
|
|
||||||
},
|
|
||||||
proxy: {
|
proxy: {
|
||||||
// 配置代理
|
// 配置代理
|
||||||
"/api": {
|
"/api": {
|
||||||
|
|||||||
@ -64,6 +64,8 @@ Route::middleware(['auth:api', 'check.permissions'])->group(function () {
|
|||||||
Route::delete('goods_sku_location', [GoodsSkuLocationController::class, 'delete'])->name('goods_sku_location.delete');
|
Route::delete('goods_sku_location', [GoodsSkuLocationController::class, 'delete'])->name('goods_sku_location.delete');
|
||||||
// 电子面单
|
// 电子面单
|
||||||
Route::get('shop/ship', [ShipController::class, 'index']);
|
Route::get('shop/ship', [ShipController::class, 'index']);
|
||||||
|
Route::get('print/orders', [BusinessOrderController::class, 'print']);
|
||||||
|
Route::put('print/success', [BusinessOrderController::class, 'printSuccess']);
|
||||||
// 发货信息
|
// 发货信息
|
||||||
Route::get('shop/ship/senders', [ShipController::class, 'getSenders']);
|
Route::get('shop/ship/senders', [ShipController::class, 'getSenders']);
|
||||||
Route::post('shop/ship/senders', [ShipController::class, 'saveSenders']);
|
Route::post('shop/ship/senders', [ShipController::class, 'saveSenders']);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user