Explorar el Código

采购入库数量导出

jbb hace 2 años
padre
commit
7f15b73765

+ 41 - 4
src/views/reportForms/fabric-loss-table/purchaseInQuantityModal.vue

@@ -27,6 +27,18 @@
             <a-col :md="6" :sm="8">
               <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
                 <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
+                <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-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
                 <a @click="handleToggleSearch" style="margin-left: 8px">
                   {{ toggleSearchStatus ? '收起' : '展开' }}
@@ -55,9 +67,9 @@
         <a-row style="marginTop:20px;">
           <a-col :md="24" :sm="12">
             <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>
@@ -69,12 +81,14 @@
 <script>
 import { JeecgListMixin } from '@/mixins/JeecgListMixin'
 import JEllipsis from '@/components/jeecg/JEllipsis'
+import JsonExcel from 'vue-json-excel'
 export default {
   name: 'PurchaseInQuantityModal', // 采购入库数量 弹框
   mixins: [JeecgListMixin],
-  components: { JEllipsis },
+  components: { JEllipsis,JsonExcel },
   data() {
     return {
+       exportTitle:"采购入库数量",
       // 表头
       purchaseInQuantityColumns: [
         {
@@ -188,6 +202,20 @@ export default {
       item.isquantityN= parseFloat(isquantityN.toFixed(4));
       return [item];
 
+    },
+    // 获取导出json定义
+    exportFields(){
+      var ret = {};
+      this.purchaseInQuantityColumns.forEach((record,index)=>{
+        if (record.title != "序号"){
+          if (record.title != "入库单号")
+            ret[record.title] = record.dataIndex;
+          else
+            ret[record.title] = record.dataIndex+"_ex";
+        }
+
+      });
+      return ret;
     }
   },
   methods: {
@@ -230,6 +258,15 @@ export default {
         ></a-table>
       )
     },
+    // 导出excel
+    exportExcel(){
+      this.$refs.realExportExcel.$el.click();
+    },
+    // 生成导出数据
+    getExportDataList(){
+      this.purchaseInQuantityData.forEach((item,index)=>{item["ccode_ex"]="&nbsp;"+item["ccode"]});
+      return this.purchaseInQuantityData;
+    }
   }
 }
 </script>