zjs_project 3 bulan lalu
induk
melakukan
b046028888
3 mengubah file dengan 10 tambahan dan 12 penghapusan
  1. 4 0
      src/api/shop.ts
  2. 2 1
      src/utils/request/index.ts
  3. 4 11
      src/views/shop/print/index.vue

+ 4 - 0
src/api/shop.ts

@@ -34,4 +34,8 @@ export function editPrinter(params?: any) {
 
 export function delPrinter(params?: any) {
     return request.post({ url: '/printer/delete', params })
+}
+
+export function print(params?: any) {
+    return request.post({ url: '/printer/print', params })
 }

+ 2 - 1
src/utils/request/index.ts

@@ -104,7 +104,8 @@ const axiosHooks: AxiosHooks = {
     responseInterceptorsCatchHook(error) {
         NProgress.done()
         if (error.code !== AxiosError.ERR_CANCELED) {
-            error.message && feedback.msgError(error.message)
+            // axios报错不提示
+            // error.message && feedback.msgError(error.message)
         }
         if (error.response && error.response.status === RequestCodeEnum.QUIT) {
             clearAuthInfo()

+ 4 - 11
src/views/shop/print/index.vue

@@ -84,7 +84,7 @@
 </template>
 <script lang="ts" setup>
 // import {articleCateDelete, articleCateStatus} from '@/api/article'
-import {delPrinter,editPrinter} from '@/api/shop'
+import {delPrinter,editPrinter,print} from '@/api/shop'
 import {usePaging} from '@/hooks/usePaging'
 import feedback from '@/utils/feedback'
 import EditPopup from './edit.vue'
@@ -154,17 +154,14 @@ const changeStatus = async (id: number,status: any) => {
 }
 
 const handlePrint = async (row: any) => {
-  const res = await feedback.request({
-    url: '/api/printer/print',
-    method: 'post',
-    data: {
+    let data = {
       id: row.id,
       brandId: row.brandId,
       houseId: row.houseId,
       orderNo: '123456789987654321',
       deskNo: '大厅',
       orderSource: '扫码支付',
-      orderTime: timeFormat(Date.now(), 'yyyy年mm月dd日 hh时MM分'),
+      orderTime: timeFormat(Date.now(), 'yyyy年mm月dd日hh时MM分'),
       remark: '测试打印机',
       userNum: '4',
       amount: '30',
@@ -175,12 +172,8 @@ const handlePrint = async (row: any) => {
         {'title': '测试菜品3', 'num': '1', 'summary': '12'}
       ]
     }
-  })
-  if (res.code == 200) {
+    await print(data);
     feedback.msgSuccess('测试打印成功')
-  } else {
-    feedback.msgError('测试打印失败')
-  }
 }
 getLists()
 </script>