瀏覽代碼

发票数量导出

jbb 2 年之前
父節點
當前提交
aa1031dab8
共有 1 個文件被更改,包括 48 次插入4 次删除
  1. 48 4
      src/views/reportForms/fabric-loss-table/invoiceQuantityModal.vue

+ 48 - 4
src/views/reportForms/fabric-loss-table/invoiceQuantityModal.vue

@@ -8,6 +8,25 @@
   >
     <!-- tabel 加载 -->
     <a-spin :spinning="confirmLoading">
+       <div class="table-page-search-wrapper">
+        <a-form layout="inline" @keyup.enter.native="searchQuery">
+          <a-row :gutter="24">
+            <a-col :md="6" :sm="8">
+               <a-button type="primary" icon="download" @click="exportExcel" style="margin-left: 8px">导出</a-button>
+                <JsonExcel
+                  :fetch="getExportDataList"
+                  :fields="exportFields"
+                  :header="exportTitle"
+                  name="采购入库数量.xls"
+                  style="display:none"
+                >
+                  <!-- 上面可以自定义自己的样式,还可以引用其他组件button -->
+                  <a-button type="primary" icon="download" ref="realExportExcel">导出</a-button>
+                </JsonExcel>
+            </a-col>
+          </a-row>
+        </a-form>
+      </div>
       <!-- table -->
       <div style="marginTop:30px;">
         <a-table
@@ -25,9 +44,9 @@
         <a-row>
           <a-col :md="24" :sm="12" style="marginTop:20px;">
             <span style="float: right;" class="table-operator">
-              <a-button type="primary" icon="download" @click="handleExportXls('采购数量')">导出</a-button>
-              <a-button type="primary" @click="print" icon="printer" style="margin:0 10px;">打印</a-button>
-              <a-button type="primary" @click="backFabricLossTable" icon="rollback">返回</a-button>
+              <!-- <a-button type="primary" icon="download" @click="handleExportXls('采购数量')">导出</a-button>
+              <a-button type="primary" @click="print" icon="printer" style="margin:0 10px;">打印</a-button> -->
+              <a-button type="primary" @click="backFabricLossTable" icon="rollback">关闭</a-button>
             </span>
           </a-col>
         </a-row>
@@ -37,11 +56,13 @@
 </template>
 
 <script>
+import JsonExcel from 'vue-json-excel'
 export default {
   name: 'InvoiceQuantityModal', // 发票数量 弹框
-  components: {},
+  components: {JsonExcel},
   data() {
     return {
+       exportTitle:"发票数量",
       // 表头
       invoiceQuantityColumns: [
         {
@@ -121,6 +142,20 @@ export default {
       item.iquantitySettleN= parseFloat(iquantitySettleN.toFixed(4));
       return [item];
 
+    },
+    // 获取导出json定义
+    exportFields(){
+      var ret = {};
+      this.invoiceQuantityColumns.forEach((record,index)=>{
+        if (record.title != "序号"){
+          if (record.title != "入库单号")
+            ret[record.title] = record.dataIndex;
+          else
+            ret[record.title] = record.dataIndex+"_ex";
+        }
+
+      });
+      return ret;
     }
   },
   methods: {
@@ -152,6 +187,15 @@ export default {
         ></a-table>
       )
     },
+     // 导出excel
+    exportExcel(){
+      this.$refs.realExportExcel.$el.click();
+    },
+    // 生成导出数据
+    getExportDataList(){
+      this.invoiceQuantityData.forEach((item,index)=>{item["ccode_ex"]="&nbsp;"+item["ccode"]});
+      return this.invoiceQuantityData;
+    }
   }
 }
 </script>