瀏覽代碼

feat(order): update

gemercheung 3 年之前
父節點
當前提交
d03f2eee80
共有 3 個文件被更改,包括 123 次插入21 次删除
  1. 36 16
      src/views/order/list.vue
  2. 82 0
      src/views/order/printModal.vue
  3. 5 5
      src/views/scenes/live.vue

+ 36 - 16
src/views/order/list.vue

@@ -57,6 +57,7 @@
       </template>
     </BasicTable>
     <ConfirmModal @register="registerConfirmModal" @reload="reload" />
+    <PrintModal @register="registerPrintModal" @reload="reload" />
   </div>
 </template>
 <script lang="ts">
@@ -72,17 +73,27 @@
   import { useMessage } from '/@/hooks/web/useMessage';
   // import { Switch } from 'ant-design-vue';
   // import { h } from 'vue';
-  import { ListApi, BrandListApi } from '/@/api/order/list';
+  import { ListApi, BrandListApi, GetOrderInfoApi } from '/@/api/order/list';
   import { useI18n } from '/@/hooks/web/useI18n';
   // import { useCopyToClipboard } from '/@/hooks/web/useCopyToClipboard';
   import { useGo } from '/@/hooks/web/usePage';
   import { Time } from '/@/components/Time';
   import { PopConfirmButton } from '/@/components/Button';
-  import printJS from 'print-js';
+  // import printJS from 'print-js';
   import { useModal } from '/@/components/Modal';
   import ConfirmModal from './confirmModal.vue';
+  import PrintModal from './printModal.vue';
+
   export default defineComponent({
-    components: { BasicTable, TableAction, TableImg, Time, PopConfirmButton, ConfirmModal },
+    components: {
+      BasicTable,
+      TableAction,
+      TableImg,
+      Time,
+      PopConfirmButton,
+      ConfirmModal,
+      PrintModal,
+    },
     setup() {
       const { createMessage } = useMessage();
       const go = useGo();
@@ -254,6 +265,8 @@
 
       const [registerConfirmModal, { openModal: openConfirmModal }] = useModal();
 
+      const [registerPrintModal, { openModal: openPrintModal }] = useModal();
+
       const [registerTable, { getSelectRowKeys, reload }] = useTable({
         title: '订单列表',
         api: ListApi,
@@ -337,21 +350,27 @@
           return;
         }
       }
-      function printDetail(record: Recordable) {
+      async function printDetail(record: Recordable) {
         console.log('record', record);
-        printJS({
-          printable: [
-            { name: '订单号', email: '20210908174503807397842', phone: '123' },
-            { name: 'qq', email: '456@gmail.com', phone: '456' },
-          ],
-          properties: ['name', 'email', 'phone'],
-          type: 'json',
-          gridHeaderStyle: 'color: red;  border: 2px solid #3971A5;',
-          gridStyle: 'border: 2px solid #3971A5;',
-          header: '<h3 class="custom-h3">订单详情</h3>',
-          documentTitle: '订单详情',
-          style: '.custom-h3 { color: red; }',
+        const orderInfo = await GetOrderInfoApi({
+          id: record.id,
+          brandId: record.brandId,
         });
+        console.log('orderInfo', orderInfo);
+        openPrintModal(true, orderInfo);
+        // printJS({
+        //   printable: [
+        //     { name: '订单号', email: '20210908174503807397842', phone: '123' },
+        //     { name: 'qq', email: '456@gmail.com', phone: '456' },
+        //   ],
+        //   properties: ['name', 'email', 'phone'],
+        //   type: 'json',
+        //   gridHeaderStyle: 'color: red;  border: 2px solid #3971A5;',
+        //   gridStyle: 'border: 2px solid #3971A5;',
+        //   header: '<h3 class="custom-h3">订单详情</h3>',
+        //   documentTitle: '订单详情',
+        //   style: '.custom-h3 { color: red; }',
+        // });
       }
 
       return {
@@ -369,6 +388,7 @@
         registerConfirmModal,
         reload,
         printDetail,
+        registerPrintModal,
       };
     },
   });

+ 82 - 0
src/views/order/printModal.vue

@@ -0,0 +1,82 @@
+<template>
+  <BasicModal v-bind="$attrs" @register="register" title="打印票据" @ok="handleSubmit" width="80%">
+    <BasicTable @register="registerTable" />
+  </BasicModal>
+</template>
+<script lang="ts">
+  // reactive
+  import { defineComponent } from 'vue';
+  import { BasicTable, useTable, BasicColumn } from '/@/components/Table';
+  import { BasicModal, useModalInner } from '/@/components/Modal';
+
+  export default defineComponent({
+    name: 'PrintModal',
+    components: { BasicModal, BasicTable },
+    emits: ['success', 'register', 'reload'],
+    setup() {
+      // const isUpdate = ref(true);
+      // let modalRecord = reactive({
+      //   id: 0,
+      //   brandId: 0,
+      // });
+      const columns: BasicColumn[] = [
+        {
+          title: '清单',
+          dataIndex: 'goodsName',
+          width: 180,
+        },
+        {
+          title: '数量',
+          dataIndex: 'orderSn',
+          ellipsis: false,
+          width: 180,
+        },
+        {
+          title: '单价',
+          dataIndex: 'orderSn',
+          ellipsis: false,
+          width: 180,
+        },
+        {
+          title: '总价',
+          dataIndex: 'orderSn',
+          ellipsis: false,
+          width: 180,
+        },
+      ];
+
+      const [registerTable] = useTable({
+        title: '订单列表',
+
+        columns: columns,
+        // useSearchForm: false,
+        // formConfig: searchForm,
+        // clickToRowSelect: false,
+        // showTableSetting: true,
+        // tableSetting: { fullScreen: true },
+        // showIndexColumn: false,
+        // rowKey: 'id',
+        pagination: false,
+
+        bordered: true,
+      });
+
+      const [register, { closeModal }] = useModalInner((data) => {
+        data && onDataReceive(data);
+      });
+      function onDataReceive(data) {
+        console.log('data', data);
+        // modalRecord = { ...data };
+        // modalRecord.brandId = data.brandId;
+      }
+      async function handleSubmit() {}
+
+      return {
+        register,
+        handleSubmit,
+        closeModal,
+        registerTable,
+      };
+    },
+  });
+</script>

+ 5 - 5
src/views/scenes/live.vue

@@ -117,7 +117,7 @@
           dataIndex: 'livestreamStatus',
           width: 180,
           customRender: ({ record }) => {
-            const enable = record.livestreamStatus === 0;
+            const enable = record.livestreamStatus === 1;
             const color = enable ? 'green' : 'red';
             const text = enable ? t('common.yes') : t('common.no');
             return h(Tag, { color: color }, () => text);
@@ -200,16 +200,16 @@
                 {
                   label: t('common.all'),
                   value: '',
-                  key: '1',
+                  key: '0',
                 },
                 {
                   label: t('common.yes'),
-                  value: '',
-                  key: '2',
+                  value: 1,
+                  key: '1',
                 },
                 {
                   label: t('common.no'),
-                  value: '0',
+                  value: 0,
                   key: '2',
                 },
               ],