qymljy 2 年之前
父节点
当前提交
a0ec0fe74f

+ 6 - 2
src/HDrpManagement/orderManage/details/export_excel.vue

@@ -23,6 +23,7 @@ export default {
       data.content.isAll = false
 
       const res = await this.$api.requested(data)
+      console.log(res,'data')
 
       if (this.specialKey){
         res.data.forEach(e=>{
@@ -34,7 +35,7 @@ export default {
       }
 
       let table = JSON.parse(JSON.stringify(this.tablecols))
-      console.log(table);
+      console.log(table,'表格数据导出');
       table.forEach((e,index) => {
         // 由于表格数据结构问题这里需要判断一下
         if (e.title === '省市县') {
@@ -61,7 +62,10 @@ export default {
             e.model = e.model + '/' + e.spec
           })
         } else if (e.title === '小计') {
-          e.deliverydate = this.tool.formatAmount(e.price * e.qty)
+          res.data.forEach(e => {
+            e.subtotal = e.price * e.qty
+            console.log(e.subtotal)
+          })
         }
       });
       let hd = table.map(e=>{

+ 81 - 0
src/HDrpManagement/toolBorrowingMag/detail/export_excel.vue

@@ -0,0 +1,81 @@
+<template>
+  <div>
+    <el-button type="primary" size="small" @click="submit()" plain >导 出</el-button>
+  </div>
+</template>
+
+<script>
+import { log } from '@antv/g2plot/lib/utils'
+export default {
+  props:['tablecols','param','excelTitle','total','specialKey'],
+  data () {
+    return {}
+  },
+  methods:{
+    async submit () {
+      let data = {}
+      // 如果传入了total,需要赋值保证数量准确性
+      // data = Object.assign({},data,this.param)
+      data = JSON.parse(JSON.stringify(this.param))
+      if (this.total) {
+        data.content.pageSize = this.total
+      }
+      data.content.isAll = false
+
+      const res = await this.$api.requested(data)
+      console.log(res,'data')
+
+      if (this.specialKey){
+        res.data.forEach(e=>{
+          this.specialKey.forEach(s=>{
+            e[s.key] = e[s.key]? e[s.key]:[]
+            e[s.key] = e[s.key].map(k=>{return s.value?k[s.value]:k}).toString()
+          })
+        })
+      }
+
+      let table = JSON.parse(JSON.stringify(this.tablecols))
+      console.log(table,'表格数据导出');
+      table.forEach((e,index) => {
+        // 由于表格数据结构问题这里需要判断一下
+        if (e.title === '省市县') {
+          table[index].title = '省'
+          table.splice(index + 1,0,{title:'市',columnname:'city'},{title:'县',columnname:'county'})
+        }else if(e.title === '需求日期'){
+          res.data.forEach(e => {
+            if (e.delivery === 0){
+              e.needdate = '不管控交期'
+            }else {
+              e.needdate = e.needdate
+            }
+          })
+        }else if(e.title === '回复交期'){
+          res.data.forEach(e => {
+            if (e.delivery === 0){
+              e.deliverydate = '不管控交期'
+            }else {
+              e.deliverydate = e.deliverydate
+            }
+          })
+        }else if(e.title === '型号/规格'){
+          res.data.forEach(e => {
+            e.model = e.model + '/' + e.spec
+          })
+        } else if (e.title === '小计') {
+          e.deliverydate = this.tool.formatAmount(e.price * e.qty)
+        }
+      });
+      let hd = table.map(e=>{
+        return e.title
+      })
+      let ft = table.map(e=>{
+        return e.columnname
+      })
+      this.tool.exportExcel(hd,ft,res.data,this.excelTitle)
+    }
+  }
+}
+
+</script>
+<style>
+</style>

+ 18 - 4
src/HDrpManagement/toolBorrowingMag/detail/tabs/toolList.vue

@@ -7,7 +7,7 @@
     ></addTool>
 
     <el-button  class="inline-16 normal-margin" v-if="tool.checkAuth($route.name,'adddispatch')" size="small" type="primary" @click="adddispatch">一键发货</el-button>
-<!--    <excel style="margin:0 0 10px 10px" :tablecols="columnTitle" :param="param" :total="total" :excelTitle="excelTitle"></excel>-->
+    <excel class="inline-16" :tablecols="columnTitle" :param="param" :total="total" :excelTitle="excelTitle"></excel>
     <uploadAllData
         v-if="data.status === '新建'"
         class="inline-16 normal-margin"
@@ -47,21 +47,24 @@
       </el-table-column>
       <el-table-column
         label="型号"
-        width="150">
+        width="150"
+        prop="model">
         <template slot-scope="scope">
           <p><span>{{scope.row.model}}</span></p>
         </template>
       </el-table-column>
       <el-table-column
           label="规格"
-          width="150">
+          width="150"
+          prop="spec">
         <template slot-scope="scope">
           <p><span>{{scope.row.spec}}</span></p>
         </template>
       </el-table-column>
       <el-table-column
         label="数量"
-        width="180">
+        width="180"
+        prop="qty">
         <template slot-scope="scope">
           <el-input-number :controls="true" controls-position='right' :step-strictly="true" v-if="type === 'edit' && !data.sa_contractid" size="mini" v-model="scope.row.qty" :min="scope.row.orderminqty" :step="scope.row.orderaddqty" label="输入数量" @change="rowChange(scope.row,scope.$index)"></el-input-number>
           <span v-else>{{scope.row.qty}}</span>
@@ -109,6 +112,7 @@
       </el-table-column>
       <el-table-column
         label="回复交期"
+        prop="deliverydate"
         width="200">
         <template slot="header" slot-scope="scope">
           <div>
@@ -163,6 +167,7 @@
         </template>
       </el-table-column>
       <el-table-column
+        prop="subtotal"
         label="小计">
         <template slot-scope="scope">
           <p style="color:red;font-weight:500">¥&nbsp;{{tool.formatAmount(scope.row.price * scope.row.qty,2)}}</p>
@@ -170,6 +175,7 @@
       </el-table-column>
       <el-table-column
         label="备注"
+        prop="remarks"
         width="300">
         <template slot-scope="scope">
           <el-input v-if="type === 'edit'" v-model="scope.row.remarks" placeholder="输入订单备注" size="mini" @change="rowChange(scope.row,scope.$index)"></el-input>
@@ -471,6 +477,14 @@ export default {
   },
   mounted () {
     this.listData()
+    this.columnTitle  = []
+    this.$refs.multipleTable.$children.forEach(obj => {
+
+      let columnChild = {'columnname':obj.prop,'filter':0,'rowindex':'','sequence':'','title':obj.label,'width':obj.width}
+      // 存到columnTitle数组中
+      this.columnTitle.push(columnChild)
+
+    })
   },
   created() {
     this.tablecolsAdd = this.tool.tabelCol(this.$route.name).addToolTable.tablecols

+ 19 - 1
src/SDrpManagement/salerToolBorrowing/detail/tabs/toolList.vue

@@ -5,6 +5,7 @@
              @addProduct="addTool" @uploadData="uploadData" @closeDrawer="listData();$emit('onSuccess')"
              class="inline-16 normal-margin" v-if="data.status === '新建'"
     ></addTool>
+    <excel class="inline-16" :tablecols="columnTitle" :param="param" :total="total" :excelTitle="excelTitle"></excel>
     <uploadAllData
         v-if="data.status === '新建'"
         class="inline-16 normal-margin"
@@ -36,6 +37,7 @@
       </el-table-column>
       <el-table-column
         label="型号"
+        prop="model"
         width="150">
         <template slot-scope="scope">
           <p><span>{{scope.row.model}}</span></p>
@@ -43,6 +45,7 @@
       </el-table-column>
       <el-table-column
           label="规格"
+          prop="spec"
           width="150">
         <template slot-scope="scope">
           <p><span>{{scope.row.spec}}</span></p>
@@ -50,6 +53,7 @@
       </el-table-column>
       <el-table-column
         label="数量"
+        prop="qty"
         width="180">
         <template slot-scope="scope">
           <el-input-number :controls="true" controls-position='right' :step-strictly="true" v-if="type === 'edit' && !data.sa_contractid" size="mini" v-model="scope.row.qty" :min="scope.row.orderminqty" :step="scope.row.orderaddqty" label="输入数量" @change="rowChange(scope.row,scope.$index)"></el-input-number>
@@ -98,6 +102,7 @@
       </el-table-column>
       <el-table-column
         label="回复交期"
+        prop="deliverydate"
         width="200">
         <template slot="header" slot-scope="scope">
           <div>
@@ -152,6 +157,7 @@
         </template>
       </el-table-column>
       <el-table-column
+        prop="subtotal"
         label="小计">
         <template slot-scope="scope">
           <p style="color:red;font-weight:500">¥&nbsp;{{tool.formatAmount(scope.row.price * scope.row.qty,2)}}</p>
@@ -159,6 +165,7 @@
       </el-table-column>
       <el-table-column
         label="备注"
+        prop="remarks"
         width="300">
         <template slot-scope="scope">
           <el-input v-if="type === 'edit'" v-model="scope.row.remarks" placeholder="输入订单备注" size="mini" @change="rowChange(scope.row,scope.$index)"></el-input>
@@ -190,11 +197,14 @@
 import addProduct from '@/template/toolBorrowingCanUseProduct/index.vue'
 import addTool from '@/template/addTool/index'
 import uploadAllData from '@/components/uploadAllData/index'
+import excel from '@/HDrpManagement/orderManage/details/export_excel'
 export default {
   props:['data','type'],
   data () {
     return {
       dataRefresh:true,
+      columnTitle:[],
+      excelTitle:'借用单明细',
       tableData:[],
       tablecolsAdd:[],
       param:{
@@ -231,7 +241,7 @@ export default {
     }
   },
   components:{
-    addProduct,addTool,uploadAllData
+    addProduct,addTool,uploadAllData,excel
   },
   methods:{
     async listData () {
@@ -433,6 +443,14 @@ export default {
   },
   mounted () {
     this.listData()
+    this.columnTitle  = []
+    this.$refs.multipleTable.$children.forEach(obj => {
+
+      let columnChild = {'columnname':obj.prop,'filter':0,'rowindex':'','sequence':'','title':obj.label,'width':obj.width}
+      // 存到columnTitle数组中
+      this.columnTitle.push(columnChild)
+
+    })
   },
   created() {
     this.tablecolsAdd = this.tool.tabelCol(this.$route.name).addToolTable.tablecols

+ 2 - 2
src/SDrpManagement/toolBorrowing/detail/tabs/toolList.vue

@@ -15,7 +15,7 @@
         idName="sa_orderitemsid"
         type="del"
     ></uploadAllData>
-    <excel style="margin:0 0 10px 10px" :tablecols="columnTitle" :param="param" :total="total" :excelTitle="excelTitle"></excel>
+    <excel class="inline-16"  :tablecols="columnTitle" :param="param" :total="total" :excelTitle="excelTitle"></excel>
     <el-table
       ref="multipleTable"
       :data="tableData"
@@ -158,7 +158,7 @@
       </el-table-column>
       <el-table-column
         label="小计"
-        prop="deliverydate">
+        prop="subtotal">
         <template slot-scope="scope">
           <p style="color:red;font-weight:500">¥&nbsp;{{tool.formatAmount(scope.row.price * scope.row.qty,2)}}</p>
         </template>