gemercheung пре 3 година
родитељ
комит
94b4f68dbd
1 измењених фајлова са 53 додато и 22 уклоњено
  1. 53 22
      src/views/order/printModal.vue

+ 53 - 22
src/views/order/printModal.vue

@@ -1,16 +1,41 @@
 <template>
 <template>
-  <BasicModal v-bind="$attrs" @register="register" title="打印票据" @ok="handleSubmit" width="80%">
-    <BasicTable @register="registerTable">
+  <BasicModal v-bind="$attrs" @register="register" title="打印票据" width="80%">
+    <BasicTable @register="registerTable" id="printTable">
       <template #tableTitle>
       <template #tableTitle>
         <div class="pb-30px pl-15px">
         <div class="pb-30px pl-15px">
           <address>
           <address>
-            <div>{{ modalRecord.consignee }}</div>
+            <div
+              ><strong>{{ modalRecord.consignee }}</strong></div
+            >
             <div>{{ modalRecord.address }}</div>
             <div>{{ modalRecord.address }}</div>
             <abbr title="phone"> 联系方式: </abbr> {{ modalRecord.mobile }}
             <abbr title="phone"> 联系方式: </abbr> {{ modalRecord.mobile }}
           </address>
           </address>
         </div>
         </div>
       </template>
       </template>
+
+      <template #toolbar>
+        <div class="pb-30px pl-15px">
+          <div
+            ><strong>单据编号 :</strong>
+            <span style="color: #1ab394">{{ modalRecord.orderSn }}</span></div
+          >
+          <div><strong>日期 :</strong> : <Time :value="modalRecord.addTime" mode="datetime" /></div>
+        </div>
+      </template>
+      <template #footer>
+        <div style="text-align: right; min-width: 100px"> 总计:¥{{ modalRecord.goodsPrice }} </div>
+      </template>
+      <template #retailPrice="{ record }">
+        <div>¥{{ record.retailPrice }} </div>
+      </template>
+      <template #marketPrice="{ record }">
+        <div>¥{{ record.marketPrice }} </div>
+      </template>
     </BasicTable>
     </BasicTable>
+
+    <template #footer>
+      <a-button type="primary" @click="handlePrint" class="mr-2">打印</a-button>
+    </template>
   </BasicModal>
   </BasicModal>
 </template>
 </template>
 <script lang="ts">
 <script lang="ts">
@@ -19,22 +44,11 @@
   import { BasicTable, useTable, BasicColumn } from '/@/components/Table';
   import { BasicTable, useTable, BasicColumn } from '/@/components/Table';
   import { BasicModal, useModalInner } from '/@/components/Modal';
   import { BasicModal, useModalInner } from '/@/components/Modal';
   import { cloneDeep } from 'lodash-es';
   import { cloneDeep } from 'lodash-es';
-  // goodsId: 77006478
-  // goodsName: "123"
-  // goodsSn: "123"
-  // goodsSpecifitionIds: null
-  // goodsSpecifitionNameValue: null
-  // id: 832
-  // isReal: null
-  // listPicUrl: "https://4dkk.4dage.com/shop/huafa/20211203/1428015744818c.jpg?x-oss-process=image/resize,m_fixed,w_400,h_400"
-  // marketPrice: 123
-  // number: 1
-  // orderId: 690
-  // productId: 2932
-  // retailPrice: 12312
+  import { Time } from '/@/components/Time';
+  import printJS from 'print-js';
   export default defineComponent({
   export default defineComponent({
     name: 'PrintModal',
     name: 'PrintModal',
-    components: { BasicModal, BasicTable },
+    components: { BasicModal, BasicTable, Time },
     emits: ['success', 'register', 'reload'],
     emits: ['success', 'register', 'reload'],
     setup() {
     setup() {
       // const isUpdate = ref(true);
       // const isUpdate = ref(true);
@@ -43,6 +57,9 @@
         address: '',
         address: '',
         consignee: '',
         consignee: '',
         mobile: '',
         mobile: '',
+        orderSn: '',
+        addTime: '',
+        goodsPrice: '',
       });
       });
       const columns: BasicColumn[] = [
       const columns: BasicColumn[] = [
         {
         {
@@ -61,16 +78,18 @@
           dataIndex: 'retailPrice',
           dataIndex: 'retailPrice',
           ellipsis: false,
           ellipsis: false,
           width: 180,
           width: 180,
+          slots: { customRender: 'retailPrice' },
         },
         },
         {
         {
           title: '总价',
           title: '总价',
           dataIndex: 'marketPrice',
           dataIndex: 'marketPrice',
           ellipsis: false,
           ellipsis: false,
           width: 180,
           width: 180,
+          slots: { customRender: 'marketPrice' },
         },
         },
       ];
       ];
 
 
-      const [registerTable, { setTableData }] = useTable({
+      const [registerTable, { setTableData, redoHeight }] = useTable({
         title: '订单列表',
         title: '订单列表',
 
 
         columns: columns,
         columns: columns,
@@ -80,7 +99,9 @@
         // showTableSetting: true,
         // showTableSetting: true,
         // tableSetting: { fullScreen: true },
         // tableSetting: { fullScreen: true },
         showIndexColumn: false,
         showIndexColumn: false,
-        maxHeight: 250,
+        // maxHeight: 250,
+        // resizeHeightOffset: 0,
+        isCanResizeParent: true,
         // rowKey: 'id',
         // rowKey: 'id',
         pagination: false,
         pagination: false,
 
 
@@ -97,21 +118,31 @@
         modalRecord.consignee = data.consignee;
         modalRecord.consignee = data.consignee;
         modalRecord.address = data.address;
         modalRecord.address = data.address;
         modalRecord.mobile = data.mobile;
         modalRecord.mobile = data.mobile;
-
+        modalRecord.orderSn = data.orderSn;
+        modalRecord.addTime = data.addTime;
+        modalRecord.goodsPrice = data.goodsPrice;
         // modalRecord.brandId = data.brandId;
         // modalRecord.brandId = data.brandId;
 
 
         nextTick(() => {
         nextTick(() => {
           setTableData(cloneDeep(data.goodsList));
           setTableData(cloneDeep(data.goodsList));
+          redoHeight();
+        });
+      }
+      async function handlePrint() {
+        printJS({
+          printable: 'printTable',
+          type: 'html',
+          style: 'table th td { border: 1px solid black; border-collapse: collapse; }  }',
         });
         });
       }
       }
-      async function handleSubmit() {}
 
 
       return {
       return {
         register,
         register,
-        handleSubmit,
+
         closeModal,
         closeModal,
         registerTable,
         registerTable,
         modalRecord,
         modalRecord,
+        handlePrint,
       };
       };
     },
     },
   });
   });