Ver código fonte

修改导出订单

gongwencan 5 meses atrás
pai
commit
3214b05bc2

+ 14 - 12
src/components/DialogTagApplyDetail.vue

@@ -221,18 +221,20 @@ export default {
       }).catch(console.error).finally(() => {})
     },
     onConfirmOrderBtnClick () {
-      this.$$request(this.$$api.updateConfirmOrder, this.oData).then((flag) => {
-        if (flag) {
-          this.$notify({
-            title: '成功',
-            message: '操作成功',
-            type: 'success',
-            position: 'bottom-right'
-          })
-          this.close()
-          this.$emit('saved')
-        }
-      }).catch(console.error).finally(() => {})
+      if (this.oData && this.oData.details.length > 0) {
+        this.$$request(this.$$api.updateConfirmOrder, this.oData).then((flag) => {
+          if (flag) {
+            this.$notify({
+              title: '成功',
+              message: '操作成功',
+              type: 'success',
+              position: 'bottom-right'
+            })
+            this.close()
+            this.$emit('saved')
+          }
+        }).catch(console.error).finally(() => {})
+      }
     },
     handleInput (value) {
       let sanitizedValue = value.replace(/[^0-9]/g, '')

+ 24 - 4
src/components/DialogTagApplyOrderExport.vue

@@ -9,9 +9,9 @@
       <div class="text-center" style="font-size:16px;font-weight:600;">标签需求订单</div>
       <div class="flex valign-center">
         <div>订单编号:</div>
-        <VueBarcode v-if="data" :value="data.orderNo" format="CODE128" :height="40" :font-size="14"></VueBarcode>
+        <VueBarcode v-if="data && data.orderNo" :value="data.orderNo" format="CODE128" :height="40" :font-size="14"></VueBarcode>
       </div>
-      <div style="width:100%;">
+      <div style="width:100%;max-height:206px; overflow-y:auto;">
         <table cellspacing="0" cellpadding="0" border="0" class="origin-table">
           <colgroup>
             <col />
@@ -59,7 +59,7 @@
           </tbody>
         </table>
       </div>
-      <div class="flex layout-gap" style="padding-top:20px;">
+      <div class="flex layout-gap" style="padding-top:30px;">
         <div class="flex flex-1" style="gap:5px">
           <label>制单人:</label>
           <div class="flex-1 fit-size"></div>
@@ -113,7 +113,7 @@ export default {
     number: 0
   }),
   methods: {
-    open (data) {
+    open (data, flag = true) {
       this.data = data
       this.visible = true
       this.details = this.data && this.data.details ? this.data.details : []
@@ -122,6 +122,12 @@ export default {
       this.formatDataTime = (!this.data || !this.data.dataTime) ? '' : new Date(data.dataTime).format('YYYY-MM-DD')
       this.amount = data.amount
       this.number = (!this.data || !this.data.details) ? 0 : this.data.details.reduce((sum, item) => sum + item.number, 0)
+
+      if (flag) {
+        this.$nextTick(() => {
+          this.onExportPdfBtnClick()
+        })
+      }
     },
     async onExportPdfBtnClick () {
       const { data } = this
@@ -133,6 +139,20 @@ export default {
     },
     onCloseBtnClick () {
       this.close()
+    },
+    async processSelectedList (selectedList) {
+      for (const item of selectedList) {
+        try {
+          this.open(item)
+          await this.$nextTick()
+          await this.delay(500)
+        } catch (error) {
+          console.error(error)
+        }
+      }
+    },
+    delay (ms) {
+      return new Promise(resolve => setTimeout(resolve, ms))
     }
   }
 }

+ 21 - 1
src/components/DialogTagPurchaseOrderExport.vue

@@ -119,7 +119,7 @@ export default {
     number: 0
   }),
   methods: {
-    open (data) {
+    open (data, flag = true) {
       this.data = data
       this.visible = true
       this.details = this.data && this.data.details ? this.data.details : []
@@ -127,6 +127,12 @@ export default {
       this.formatDataTime = (!this.data || !this.data.dataTime) ? '' : new Date(data.dataTime).format('YYYY-MM-DD')
       this.amount = data.amount
       this.number = (!this.data || !this.data.details) ? 0 : this.data.details.reduce((sum, item) => sum + item.number, 0)
+
+      if (flag) {
+        this.$nextTick(() => {
+          this.onExportPdfBtnClick()
+        })
+      }
     },
     async onExportPdfBtnClick () {
       const { data } = this
@@ -141,6 +147,20 @@ export default {
     },
     onPrintBtnClick () {
       this.$refs.pdfExporter.print()
+    },
+    async processSelectedList (selectedList) {
+      for (const item of selectedList) {
+        try {
+          this.open(item)
+          await this.$nextTick()
+          await this.delay(500)
+        } catch (error) {
+          console.error(error)
+        }
+      }
+    },
+    delay (ms) {
+      return new Promise(resolve => setTimeout(resolve, ms))
     }
   }
 }

+ 18 - 6
src/views/TagApply.vue

@@ -62,7 +62,7 @@
           @click="onOpenEditorBtnClick"
         >导入数据</el-button>
         <el-button
-          :disabled="!selectedData"
+          :disabled="selectedList.length === 0"
           icon="el-icon-download"
           plain
           type="primary"
@@ -243,11 +243,23 @@ export default {
         this.$refs.tagApplyDetailDialog.open(data)
       }
     },
-    onExportOrderBtnClick () {
-      this.$$request(TagApply.$$api.getDetail, this.selectedData, this)
-        .then(data => {
-          this.$refs.orderExportDialog.open(data)
-        }).catch(console.error).finally(() => {})
+    async onExportOrderBtnClick () {
+      const dataList = []
+      const promises = this.selectedList.map(item => {
+        return this.$$request(TagApply.$$api.getDetail, item, this)
+          .then(data => {
+            dataList.push(data)
+          })
+          .catch(console.error)
+      })
+      await Promise.all(promises)
+      if (dataList.length > 0) {
+        if (dataList.length === 1) {
+          this.$refs.orderExportDialog.open(dataList[0], false)
+        } else {
+          await this.$refs.orderExportDialog.processSelectedList(dataList)
+        }
+      }
     },
     onExportTemplateBtnClick () {
       this.$refs.dialogExportTemplate.open()

+ 18 - 6
src/views/TagPurchase.vue

@@ -53,7 +53,7 @@
           >新建采购</el-button>
 
           <el-button
-            :disabled="!selectedData"
+            :disabled="selectedList.length === 0"
             icon="el-icon-download"
             plain
             type="primary"
@@ -203,11 +203,23 @@ export default {
         }
       }).catch(console.error).finally(() => {})
     },
-    onExportOrderBtnClick () {
-      this.$$request(TagPurchase.$$api.getDetail, this.selectedData, this)
-        .then(data => {
-          this.$refs.orderExportDialog.open(data)
-        }).catch(console.error).finally(() => {})
+    async onExportOrderBtnClick () {
+      const dataList = []
+      const promises = this.selectedList.map(item => {
+        return this.$$request(TagPurchase.$$api.getDetail, item, this)
+          .then(data => {
+            dataList.push(data)
+          })
+          .catch(console.error)
+      })
+      await Promise.all(promises)
+      if (dataList.length > 0) {
+        if (dataList.length === 1) {
+          this.$refs.orderExportDialog.open(dataList[0], false)
+        } else {
+          await this.$refs.orderExportDialog.processSelectedList(dataList)
+        }
+      }
     },
     onOpenDetailEditorBtnClick (data) {
       this.$$request(TagPurchase.$$api.getDetail, data, this)