Переглянути джерело

3.0.39 抽盘增加下载上传数据

liuyanpeng 2 роки тому
батько
коміт
fdc9f1663d
2 змінених файлів з 86 додано та 3 видалено
  1. 1 1
      package.json
  2. 85 2
      src/components/customer/AssetInventoryStep5.vue

+ 1 - 1
package.json

@@ -1,7 +1,7 @@
 {
   "name": "client-eam-v3",
   "description": "Leanwo Prodog Client",
-  "version": "3.0.38",
+  "version": "3.0.39",
   "author": "yangzhijie1488 <yangzhijie1488@163.com>",
   "scripts": {
     "dev": "cross-env webpack serve --config ./webpack.dev.js",

+ 85 - 2
src/components/customer/AssetInventoryStep5.vue

@@ -24,6 +24,15 @@
           <button type="button" class="btn btn-danger" @click="clearFilter">
             {{ $t("lang.AssetInventorySearch.empty") }}
           </button>
+          <a-button style="height: 33.5px" type="primary" @click="downloadFile">下载</a-button>
+          <a-upload
+            v-model:file-list="fileList"
+            :show-upload-list="false"
+            :before-upload="beforeUpload"
+            @change="uploadFileChange"
+          >
+            <a-button type="dashed" style="height: 33.5px"> 上传 </a-button>
+          </a-upload>
         </div>
       </div>
       <!-- <div class="grid-item-row2-column1">
@@ -37,7 +46,7 @@
         </div>
       </div> -->
 
-      <div class="grid-item-row1-column2">
+      <div class="grid-item-row1-column2" style="margin-left: 100px">
         <a-form-item label="盘点单名称">
           <a-input v-model:value="inventorySheetName" size="default" />
         </a-form-item>
@@ -551,6 +560,7 @@ import ProjectItemTree from '../../widget/ProjectItemTree.vue';
 import AssetCategoryTree from '../../widget/AssetCategoryTree.vue';
 
 import { Notify, Uuid } from 'pc-component-v3';
+import { message } from 'ant-design-vue';
 
 export default {
   components: {
@@ -657,6 +667,7 @@ export default {
       inventorySheetName: undefined, //盘点单名称
       assetInstancesTempory: [], //盘点清单展示
       modal1: false,
+      fileList: [],
     };
   },
 
@@ -688,9 +699,81 @@ export default {
     });
   },
   methods: {
+    // 下载文件
+    downloadFile: function () {
+      const loginInfo = JSON.parse(localStorage.getItem('#LoginInfo'));
+      const envClientId = loginInfo.loginClientId;
+      $.ajax({
+        url: Common.getApiURL(
+          `ExcelReportResource/execute/20231121_164158?processReportNo=20231121_164158&envClientId=${envClientId}`,
+        ),
+        type: 'get',
+        xhrFields: {
+          responseType: 'blob',
+        },
+        beforeSend: function (request) {
+          Common.addTokenToRequest(request);
+        },
+        success: function (data) {
+          const blobUrl = window.URL.createObjectURL(data);
+          const link = document.createElement('a');
+          link.href = blobUrl;
+          link.style.display = 'none';
+          link.download = '抽盘数据.xlsx';
+          document.body.appendChild(link);
+          link.click();
+          URL.revokeObjectURL(blobUrl);
+          document.body.removeChild(link);
+        },
+        error: function (XMLHttpRequest, textStatus, errorThrown) {
+          Common.processException(XMLHttpRequest, textStatus, errorThrown);
+        },
+      });
+    },
+    // 上传文件事件
+    uploadFileChange: function ({ file }) {
+      const _self = this;
+      const formData = new FormData();
+      formData.append('file', file);
+      $.ajax({
+        url: Common.getApiURL(
+          'AssetInstanceResource/assetInstanceLedgerUpload',
+        ),
+        type: 'post',
+        beforeSend: function (request) {
+          Common.addTokenToRequest(request);
+        },
+        data: formData,
+        contentType: false,
+        processData: false,
+        success: function ({ errorCode,datas }) {
+          if (errorCode === 0) {
+            if(datas){
+              datas.forEach(item =>{
+                item.name = item.assetName;
+                item.no = item.assetCardNo;
+                item.categoryName = item.assetCategory;
+                _self.assetInstancesTempory.push(item);
+              });
+            }
+            message.success('上传成功,已加入至盘点清单', 5);
+          } else {
+            message.error('上传失败');
+          }
+          _self.loading = false;
+        },
+        error: function (XMLHttpRequest, textStatus, errorThrown) {
+          _self.loading = false;
+          Common.processException(XMLHttpRequest, textStatus, errorThrown);
+        },
+      });
+    },
+    // 取消默认上传
+    beforeUpload: function () {
+      return false;
+    },
     // 选择责任人
     custodianNameValueChanged: function (newResponsibilityFieldValue) {
-      console.log('1111111111');
       this.custodianNameFieldValue = newResponsibilityFieldValue;
       if (this.custodianNameFieldValue != null) {
         this.filter.custodianId = this.custodianNameFieldValue.id;