黄梓星 2 years ago
parent
commit
a8ca191fba

+ 18 - 0
src/api/purchase/DemandSummary.js

@@ -75,4 +75,22 @@ export function reloadBatch(data) {
     method: 'post',
     data: data
   })
+}
+// 采购需求汇总列表导出
+export function exportList(data) {
+  return request({
+    url: `/pu/demand/item/list/export`,
+    method: 'post',
+    data: data,
+    responseType: 'blob'
+  })
+}
+// 采购需求汇总明细导出
+export function exportItems(data) {
+  return request({
+    url: `/pu/demand/item/exports`,
+    method: 'post',
+    data: data,
+    responseType: 'blob'
+  })
 }

+ 52 - 4
src/views/purchase/DemandSummary/index.vue

@@ -375,7 +375,7 @@ import Refers from '@/components/Refers/refers.vue'
 import TreeRefers from '@/components/Refers/treeRefer.vue'
 import popDialog from '@/components/PopDialog/index.vue'
 import CollapseTransition from '@/components/MyCollapse/collapse.vue'
-import {getSummaryList, auditSummary, confirmSummary , cancelSummary , shutDownSummary, editSummaryList } from '@/api/purchase/DemandSummary.js'
+import {getSummaryList, auditSummary, confirmSummary , cancelSummary , shutDownSummary, editSummaryList, exportList, exportItems } from '@/api/purchase/DemandSummary.js'
 export default {
   name: 'demandSummary',
   dicts: ['sys_row_status', 'predictive_classify', 'sys_period_unit', 'sys_business', 'sys_bill_source'],
@@ -577,7 +577,53 @@ export default {
       console.log('选中数组', this.ids.join())
     },
     handleCommand(command) {
-      alert(command)
+      if(command == 'Excel导出') {
+        if(this.allSelection.length == 0) {
+          this.$modal.msgWarning("请选中至少一条数据");
+        } else {
+          exportList(this.allSelection).then(res => {
+            const blob = new Blob([res], {
+              type: "application/vnd.ms-excel;charset=UTF-8",
+            });// 创建一个类文件对象:Blob对象表示一个不可变的、原始数据的类文件对象
+            const downloadElement = document.createElement("a"); //创建a标签
+            const href = window.URL.createObjectURL(blob); // 创建下载的链接
+            // var temp = res.headers["content-disposition"]; 
+            // var fileName = decodeURIComponent(temp.split("filename=")[1]); // 中文需要转码 (前端乱码)
+            // var name = fileName.split(";")[0]; //切割成文件名
+            downloadElement.href = href;  //下载地址
+            downloadElement.download = '导出Excel'; // 下载后文件名
+            document.body.appendChild(downloadElement);
+            downloadElement.click(); // 点击下载
+            document.body.removeChild(downloadElement); // 下载完成移除元素
+            window.URL.revokeObjectURL(href); // 释放blob对象
+          })
+        }
+      }
+
+      if (command == '导出明细') {
+        if (this.allSelection.length == 0 || this.allSelection.length > 1) {
+          this.$modal.msgWarning("明细只能进行单条导出!");
+        } else {
+          let param = this.queryParams
+          param.sumFlag = this.allSelection[0].sumFlag
+          exportItems(param).then(res => {
+            const blob = new Blob([res], {
+              type: "application/vnd.ms-excel;charset=UTF-8",
+            });// 创建一个类文件对象:Blob对象表示一个不可变的、原始数据的类文件对象
+            const downloadElement = document.createElement("a"); //创建a标签
+            const href = window.URL.createObjectURL(blob); // 创建下载的链接
+            // var temp = res.headers["content-disposition"]; 
+            // var fileName = decodeURIComponent(temp.split("filename=")[1]); // 中文需要转码 (前端乱码)
+            // var name = fileName.split(";")[0]; //切割成文件名
+            downloadElement.href = href;  //下载地址
+            downloadElement.download = '导出明细'; // 下载后文件名
+            document.body.appendChild(downloadElement);
+            downloadElement.click(); // 点击下载
+            document.body.removeChild(downloadElement); // 下载完成移除元素
+            window.URL.revokeObjectURL(href); // 释放blob对象
+          })
+        }
+      }
     },
     check(row) {
       this.isList = false
@@ -620,8 +666,10 @@ export default {
         this.$modal.msgWarning("请选中至少一条数据");
       } else {
         confirmSummary(this.allSelection).then(res => {
-          this.$modal.msgSuccess("确认成功");
-          this.getList(this.queryParams)
+          if (res.code === 200) {
+            this.$modal.msgSuccess("确认成功");
+            this.getList(this.queryParams)
+          }
         })
       }
     },

+ 6 - 6
src/views/purchase/PurchaseDemandList/add.vue

@@ -400,22 +400,22 @@
               </el-form-item>
             </template>
           </el-table-column>
-          <el-table-column show-overflow-tooltip label="补单供应商编码" align="center"  prop="additionalSupplier" width="200px">
+          <el-table-column show-overflow-tooltip label="补单供应商" align="center"  prop="additionalSupplierName" width="200px">
             <template slot-scope="scope">
-              <el-form-item class="hang" :prop="'puDemandItemList.' + scope.$index + '.' + 'additionalSupplier'" :rules="{ required: isBDXQ, message: '请选择补单供应商', trigger: 'blur' }">
-                <el-input clearable :disabled="sonDisable || BDZT" size="mini" v-model="scope.row.additionalSupplier" @clear="clearHang(scope.$index, '选择补单供应商')" @focus="chooseDept(scope.$index, 'SUPPLIER_PARAM', true, '选择补单供应商')">
+              <el-form-item class="hang" :prop="'puDemandItemList.' + scope.$index + '.' + 'additionalSupplierName'" :rules="{ required: isBDXQ, message: '请选择补单供应商', trigger: 'blur' }">
+                <el-input clearable :disabled="sonDisable || BDZT" size="mini" v-model="scope.row.additionalSupplierName" @clear="clearHang(scope.$index, '选择补单供应商')" @focus="chooseDept(scope.$index, 'SUPPLIER_PARAM', true, '选择补单供应商')">
                   <el-button size="mini" :disabled="sonDisable || BDZT" slot="append" icon="el-icon-more" @click="chooseDept(scope.$index, 'SUPPLIER_PARAM', true, '选择补单供应商')"></el-button>
                 </el-input>
               </el-form-item>
             </template>
           </el-table-column>
-          <el-table-column show-overflow-tooltip label="补单供应商名称" align="center"  prop="additionalSupplierName" width="200px">
+          <!-- <el-table-column show-overflow-tooltip label="补单供应商名称" align="center"  prop="additionalSupplierName" width="200px">
             <template slot-scope="scope">
               <el-form-item class="hang">
                 <el-input readonly size="mini" v-model="scope.row.additionalSupplierName"/>
               </el-form-item>
             </template>
-          </el-table-column>
+          </el-table-column> -->
           <!-- <el-table-column show-overflow-tooltip label="周期单位" align="center"  prop="periodUnit" width="150px">
             <template slot-scope="scope">
               <el-form-item class="hang">
@@ -1100,7 +1100,7 @@ export default {
         this.basicForm.puDemandItemList[this.tableIndex].deliveryAllocationName = selection[0].name
       }
       if(this.referCondition.title == '选择补单供应商') {
-        this.basicForm.puDemandItemList[this.tableIndex].additionalSupplier = selection[0].code
+        this.basicForm.puDemandItemList[this.tableIndex].additionalSupplier = selection[0].id
         this.basicForm.puDemandItemList[this.tableIndex].additionalSupplierName = selection[0].name
       }
       if(this.referCondition.title == '选择收货地址') {