|
|
@@ -163,12 +163,20 @@
|
|
|
size="mini"
|
|
|
:disabled="!isPaid(scope.row)"
|
|
|
@click="printA4(scope.row)"
|
|
|
+ style="display:none"
|
|
|
>打印A4</el-button>
|
|
|
+ <el-button
|
|
|
+ type="text"
|
|
|
+ size="mini"
|
|
|
+ :disabled="!isPaid(scope.row)"
|
|
|
+ @click="printA4Local(scope.row)"
|
|
|
+ >打A4</el-button>
|
|
|
<el-button
|
|
|
type="text"
|
|
|
size="mini"
|
|
|
:disabled="!isPaid(scope.row)"
|
|
|
@click="printGreetingCard(scope.row)"
|
|
|
+ style="display:none"
|
|
|
>打印贺卡</el-button>
|
|
|
<el-button
|
|
|
type="text"
|
|
|
@@ -211,6 +219,7 @@ import GoodsDetailDialog from './components/goods-detail-dialog';
|
|
|
import CallDeliveryDialog from './components/call-delivery-dialog';
|
|
|
import BeginRefundDialog from './components/begin-refund-dialog';
|
|
|
import RefundRecordDialog from './components/refund-record-dialog';
|
|
|
+import { hiprint } from 'vue-plugin-hiprint';
|
|
|
|
|
|
const STATUS_MAP = { 1: '待付款', 2: '待配送', 3: '配送中', 4: '已完结', 5: '已取消', 6: '已退款' };
|
|
|
const FROM_TYPE_MAP = { 1: '门店', 2: '商城', 3: '微信', 4: '美团', 5: '饿了么' };
|
|
|
@@ -451,6 +460,42 @@ export default {
|
|
|
})
|
|
|
.catch(() => {});
|
|
|
},
|
|
|
+ /**
|
|
|
+ * 本地 hiprint 打 A4:对齐 ghs 打A4,版式用 hd 配送单模板
|
|
|
+ * 拉 /order/a4-print-info → hiprint.print → 累加打印次数
|
|
|
+ */
|
|
|
+ printA4Local(row) {
|
|
|
+ if (!this.isPaid(row)) return;
|
|
|
+ const loading = this.$loading({ lock: true, text: '正在准备打印...' });
|
|
|
+ this.$service.order
|
|
|
+ .a4PrintInfo({ id: row.id })
|
|
|
+ .then(res => {
|
|
|
+ const printData = res.printData || '';
|
|
|
+ const str = res.template || '';
|
|
|
+ if (!str) {
|
|
|
+ return Promise.reject(new Error('未获取到打印模板'));
|
|
|
+ }
|
|
|
+ let template;
|
|
|
+ try {
|
|
|
+ template = JSON.parse(str);
|
|
|
+ } catch (e) {
|
|
|
+ return Promise.reject(new Error('打印模板解析失败'));
|
|
|
+ }
|
|
|
+ const hiprintTemplate = new hiprint.PrintTemplate({ template });
|
|
|
+ hiprintTemplate.print(printData);
|
|
|
+ return this.$service.order.addPrintNum({ id: row.id });
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ this.refreshData();
|
|
|
+ })
|
|
|
+ .catch(err => {
|
|
|
+ // 仅本地模板校验失败提示;接口错误由 request 拦截器已提示
|
|
|
+ if (err && err.message && /打印模板/.test(err.message)) {
|
|
|
+ this.$message.error(err.message);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .finally(() => loading.close());
|
|
|
+ },
|
|
|
/**
|
|
|
* 打印贺卡:确认后调链科云打印 /order/cloud-print-greeting-card
|
|
|
*/
|
|
|
@@ -653,7 +698,7 @@ export default {
|
|
|
op: {
|
|
|
visible: true,
|
|
|
props: {
|
|
|
- width: 320,
|
|
|
+ width: 360,
|
|
|
align: 'center',
|
|
|
fixed: 'right',
|
|
|
label: '操作'
|