Эх сурвалжийг харах

Merge branch 'dev' into 'purchaseDev'

Dev

See merge request new-business/drp-web!396
黄梓星 1 жил өмнө
parent
commit
99e30a9b93

+ 9 - 0
src/api/business/purchase/apply.js

@@ -48,3 +48,12 @@ export function mbDownload(data) {
     responseType: 'blob'
   })
 }
+// 导入失败文件下载
+export function failDownload(data) {
+  return request({
+    url: `/pu/priceApply/downloadFailData`,
+    method: 'post',
+    data: data,
+    responseType: 'blob'
+  })
+}

+ 1 - 2
src/views/purchase/apply/add/columns.js

@@ -326,8 +326,7 @@ export default function useColumns() {
           attr: {
             formatter: (prop) => {
               const { taxPrice = 0, recentlyPrice = 0 } = prop;
-              return (prop.priceDiffer =
-                Number(taxPrice) - Number(recentlyPrice));
+              return (prop.priceDiffer = Number(recentlyPrice) !== 0 ? Number(taxPrice) - Number(recentlyPrice) : 0);
             },
           },
         },

+ 1 - 3
src/views/purchase/apply/copy/columns.js

@@ -326,9 +326,7 @@ export default function useColumns() {
           attr: {
             formatter: (prop) => {
               const { taxPrice = 0, recentlyPrice = 0 } = prop;
-              return (prop.priceDiffer = (
-                Number(taxPrice) - Number(recentlyPrice)
-              ));
+              return (prop.priceDiffer = Number(recentlyPrice) !== 0 ? Number(taxPrice) - Number(recentlyPrice) : 0);
             },
           },
         },

+ 1 - 3
src/views/purchase/apply/edit/columns.js

@@ -326,9 +326,7 @@ export default function useColumns() {
           attr: {
             formatter: (prop) => {
               const { taxPrice = 0, recentlyPrice = 0 } = prop;
-              return (prop.priceDiffer = (
-                Number(taxPrice) - Number(recentlyPrice)
-              ));
+              return (prop.priceDiffer = Number(recentlyPrice) !== 0 ? Number(taxPrice) - Number(recentlyPrice) : 0 );
             },
           },
         },

+ 92 - 2
src/views/purchase/apply/index.vue

@@ -1,7 +1,9 @@
 <script>
 import { dicts } from "./dicts";
 import useColumns from "./columns";
-import { LIST, mbDownload } from "@/api/business/purchase/apply";
+import { LIST, mbDownload, failDownload} from "@/api/business/purchase/apply";
+// 导入的token
+import { getToken } from "@/utils/auth";
 
 export default {
   name: "PuchaseApply",
@@ -21,6 +23,21 @@ export default {
     const page = this.$init.page();
     const params = this.$init.params(SearchColumns);
     return {
+      // 导入参数
+      upload: {
+        // 是否显示弹出层(导入)
+        open: false,
+        // 弹出层标题(导入)
+        title: "数据导入",
+        // 是否禁用上传
+        isUploading: false,
+        // 是否更新已经存在的用户数据
+        updateSupport: 1,
+        // 设置上传的请求头部
+        headers: { Authorization: "Bearer " + getToken() },
+        // 上传的地址
+        url: process.env.VUE_APP_BASE_API + "/pu/priceApply/import"
+      },
       size: "mini",
       loading: false,
       params: params,
@@ -99,9 +116,52 @@ export default {
         this.$modal.closeLoading();
       })
     },
+    // 文件上传中处理
+    handleFileUploadProgress(event, file, fileList) {
+      this.upload.isUploading = true;
+      this.$modal.loading("正在导入数据,请稍后...");
+    },
+    // 文件上传成功处理
+    handleFileSuccess(response, file, fileList) {
+      this.$modal.closeLoading();
+      this.upload.open = false;
+      this.upload.isUploading = false;
+      this.$refs.upload.clearFiles();
+      this.$alert(response.data.msg, "导入结果", { dangerouslyUseHTMLString: true });
+      // 有失败的再次下载下来
+      if(response.data.flag) {
+        this.$modal.loading("正在下载导入失败数据,请稍后...");
+        failDownload({failDatas:response.data.datas}).then(res => {
+          this.$modal.closeLoading();
+          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); // 创建下载的链接
+          downloadElement.href = href;  //下载地址
+          downloadElement.download = '价格申报单导入失败数据' + this.parseTime(new Date().getTime()) + ".xlsx"; // 下载后文件名
+          document.body.appendChild(downloadElement);
+          downloadElement.click(); // 点击下载
+          document.body.removeChild(downloadElement); // 下载完成移除元素
+          window.URL.revokeObjectURL(href); // 释放blob对象
+        }).catch(err => {
+          this.$modal.closeLoading();
+        })
+      }
+      this.useQuery(this.params, this.page);
+    },
+    errorFile(err) {
+      this.$modal.closeLoading();
+      this.$modal.notifyError("文件已变动,请重新上传");
+    },
+    // 提交上传文件
+    submitFileForm() {
+      this.$refs.upload.submit();
+    },
     // 导入数据
     importMb() {
-
+      this.upload.title = "文件导入"
+      this.upload.open = true
     },
   },
 };
@@ -190,6 +250,36 @@ export default {
       @pagination="useQuery(params, page)"
     >
     </el-super-table>
+    <!-- 文件导入对话框 -->
+    <el-dialog title="文件导入" :visible.sync="upload.open" width="400px">
+      <el-upload
+      ref="upload"
+      :limit="1"
+      accept=".xlsx, .xls"
+      :headers="upload.headers"
+      :action="upload.url + '?updateSupport=' + upload.updateSupport"
+      :disabled="upload.isUploading"
+      :on-progress="handleFileUploadProgress"
+      :on-success="handleFileSuccess"
+      :on-error="errorFile"
+      :auto-upload="false"
+      drag
+      >
+      <i class="el-icon-upload"></i>
+      <div class="el-upload__text">
+        将文件拖到此处,或
+        <em>点击上传</em>
+      </div>
+      <!-- <div class="el-upload__tip" slot="tip">
+        <el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据
+      </div> -->
+      <div class="el-upload__tip" style="color:red" slot="tip">提示:仅允许导入“xls”或“xlsx”格式文件!</div>
+      </el-upload>
+      <div slot="footer">
+      <el-button size="mini" type="primary" @click="submitFileForm">确 定</el-button>
+      <el-button size="mini" @click="upload.open = false">取 消</el-button>
+      </div>
+    </el-dialog>
   </el-card>
 </template>
 <style scoped lang="scss">

+ 9 - 10
src/views/purchase/task/xie-yi-zhi-cai/column.js

@@ -19,7 +19,15 @@ export const TableColumns = [
      
     },
   },
-  
+  {
+    item: { key: "taxPrice", title: "主含税单价", width: 150 },
+    attr: {
+      is: "el-computed-input-v2",
+      formatter: (prop) => {
+        return (prop * 1);
+      },
+    },
+  },
   
   // {
   //   item: { key: "customerName", title: "客户" },
@@ -56,15 +64,6 @@ export const TableColumns = [
     },
   },
   {
-    item: { key: "taxPrice", title: "主含税单价",width:150 },
-    attr: {
-      is: "el-computed-input-v2",
-      formatter: (prop) => {
-        return (prop * 1);
-      },
-    },
-  },
-  {
     item: { key: "purchaseQuantity", title: "本次采购数量", fixed: true ,width:160},
     attr: {
       is: "el-input-number",