物资厂家管理
This commit is contained in:
		
							parent
							
								
									0596f2a887
								
							
						
					
					
						commit
						4f078ed5a7
					
				| 
						 | 
				
			
			@ -54,5 +54,12 @@ export function addFacturer(data) {
 | 
			
		|||
  })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
//删除服务器中的文件
 | 
			
		||||
export function deleteFile(objectKey) {
 | 
			
		||||
  return request({
 | 
			
		||||
      url: '/file/deleteFile',
 | 
			
		||||
      method: 'delete',
 | 
			
		||||
      params:{objectKey}
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -183,6 +183,7 @@
 | 
			
		|||
              :file-list="businessLicenseListTemp"
 | 
			
		||||
              :show-file-list="true"
 | 
			
		||||
              :auto-upload="false"
 | 
			
		||||
              :key="uploadKey"
 | 
			
		||||
              list-type="picture-card"
 | 
			
		||||
              accept=".png, .jpg, .jpeg, .pdf"
 | 
			
		||||
              :on-change="handleChangeBusinessList"
 | 
			
		||||
| 
						 | 
				
			
			@ -230,15 +231,16 @@
 | 
			
		|||
  </template> 
 | 
			
		||||
  
 | 
			
		||||
  <script>
 | 
			
		||||
  import { getListFacturer,getFacturerDetail,editFacturer,addFacturer,delFacturer } from "@/api/ma/supplier";
 | 
			
		||||
  import { getListFacturer,getFacturerDetail,editFacturer,addFacturer,delFacturer,deleteFile } from "@/api/ma/supplier";
 | 
			
		||||
  import { imgUpLoadThree, fileUpLoad } from '@/api/system/upload'
 | 
			
		||||
  import { downloadFile,downloadFileData } from '@/utils/download'
 | 
			
		||||
  import { getToken } from '@/utils/auth'
 | 
			
		||||
import { forEach } from 'jszip';
 | 
			
		||||
  import { forEach } from 'jszip';
 | 
			
		||||
  export default {
 | 
			
		||||
    name: "supplier",
 | 
			
		||||
    data() {
 | 
			
		||||
      return {
 | 
			
		||||
        uploadKey: Date.now(),
 | 
			
		||||
        // 遮罩层
 | 
			
		||||
        loading: false,
 | 
			
		||||
  
 | 
			
		||||
| 
						 | 
				
			
			@ -295,6 +297,7 @@ import { forEach } from 'jszip';
 | 
			
		|||
        businessLicenseFileList:[],
 | 
			
		||||
        businessLicenseListTemp:[],
 | 
			
		||||
        delBusinessFileIdList:[],
 | 
			
		||||
        modelIdTemp:undefined,
 | 
			
		||||
       //图片查看弹窗
 | 
			
		||||
        dialogImageUrl: '',
 | 
			
		||||
        dialogVisible: false,
 | 
			
		||||
| 
						 | 
				
			
			@ -385,6 +388,10 @@ import { forEach } from 'jszip';
 | 
			
		|||
              }
 | 
			
		||||
          })
 | 
			
		||||
          this.businessLicenseListTemp.splice(sum, 1)
 | 
			
		||||
          if(file.status=='success'){
 | 
			
		||||
          this.delBusinessFileIdList.push(file.url);
 | 
			
		||||
          }
 | 
			
		||||
           console.log('delBusinessFileIdList',this.delBusinessFileIdList)
 | 
			
		||||
      },
 | 
			
		||||
 | 
			
		||||
        isImage(file){
 | 
			
		||||
| 
						 | 
				
			
			@ -480,6 +487,8 @@ import { forEach } from 'jszip';
 | 
			
		|||
        /** 新增按钮操作 */
 | 
			
		||||
        handleAdd() {
 | 
			
		||||
        this.reset()
 | 
			
		||||
        this.uploadKey = Date.now();
 | 
			
		||||
        this.delBusinessFileIdList=[];
 | 
			
		||||
        this.businessLicenseListTemp=[];
 | 
			
		||||
        this.businessLicenseFileList=[];
 | 
			
		||||
        this.showHouse = true
 | 
			
		||||
| 
						 | 
				
			
			@ -488,19 +497,24 @@ import { forEach } from 'jszip';
 | 
			
		|||
 | 
			
		||||
        handleUpdate(row){
 | 
			
		||||
          this.reset()
 | 
			
		||||
          this.uploadKey = Date.now();
 | 
			
		||||
          this.delBusinessFileIdList=[];
 | 
			
		||||
          this.businessLicenseListTemp=[];
 | 
			
		||||
          this.businessLicenseFileList=[];
 | 
			
		||||
          const supplierId = row.supplierId 
 | 
			
		||||
          const supplierId = row.supplierId;
 | 
			
		||||
          this.modelIdTemp = row.supplierId;
 | 
			
		||||
            getFacturerDetail(supplierId).then((response) => {
 | 
			
		||||
                this.form = response.data;
 | 
			
		||||
                if(response.data.bmFileInfos!=null){
 | 
			
		||||
                this.businessLicenseListTemp = response.data.bmFileInfos;
 | 
			
		||||
                this.businessLicenseListTemp.forEach(item=>{
 | 
			
		||||
                  if(item.name.includes('/')){
 | 
			
		||||
                  const fileNameWithTimestamp = item.name.split('/').pop();
 | 
			
		||||
                  const parts = fileNameWithTimestamp.split('_'); // 按下划线分割
 | 
			
		||||
                   const fileType = item.name.split('.').pop();
 | 
			
		||||
                  const mainFileName = parts.slice(0, parts.length - 1).join('_');
 | 
			
		||||
                  item.name = mainFileName + '.' +fileType;
 | 
			
		||||
                  }
 | 
			
		||||
                })
 | 
			
		||||
                }else{
 | 
			
		||||
                this.businessLicenseListTemp = [];
 | 
			
		||||
| 
						 | 
				
			
			@ -531,8 +545,10 @@ import { forEach } from 'jszip';
 | 
			
		|||
                if(this.businessLicenseListTemp.length!=0){
 | 
			
		||||
                  await  this.getImaUploadEdit(),
 | 
			
		||||
                  await this.editFacturerTemp(this.form);
 | 
			
		||||
                  await this.deleteFile();
 | 
			
		||||
                }else{
 | 
			
		||||
                   await this.editFacturerTemp(this.form);
 | 
			
		||||
                   await this.deleteFile();
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
              } else {
 | 
			
		||||
| 
						 | 
				
			
			@ -546,6 +562,8 @@ import { forEach } from 'jszip';
 | 
			
		|||
            }
 | 
			
		||||
            }
 | 
			
		||||
            });
 | 
			
		||||
                   
 | 
			
		||||
                    this.uploadKey = Date.now();
 | 
			
		||||
        },
 | 
			
		||||
 | 
			
		||||
       async getImaUpload(){
 | 
			
		||||
| 
						 | 
				
			
			@ -570,7 +588,7 @@ import { forEach } from 'jszip';
 | 
			
		|||
            console.log('fileTwo',fileTwo)
 | 
			
		||||
            this.businessLicenseListTemp.forEach(item=>{
 | 
			
		||||
                if(item.status=='success'){
 | 
			
		||||
                  let objThree = { 'name': item.name, 'url': item.url,'modelId': null, 'dicId':4 };
 | 
			
		||||
                  let objThree = { 'name': item.name, 'url': item.url,'modelId': this.modelIdTemp, 'dicId':4 };
 | 
			
		||||
                  this.businessLicenseFileList.push(objThree);
 | 
			
		||||
                }
 | 
			
		||||
               })
 | 
			
		||||
| 
						 | 
				
			
			@ -578,7 +596,7 @@ import { forEach } from 'jszip';
 | 
			
		|||
            let res = await imgUpLoadThree(fileTwo);
 | 
			
		||||
            if (res.code === 200) {
 | 
			
		||||
                res.data.forEach(item=>{
 | 
			
		||||
                let objTwo = { 'name': item.name, 'url': item.url,'modelId': null, 'dicId':4 };
 | 
			
		||||
                let objTwo = { 'name': item.name, 'url': item.url,'modelId': this.modelIdTemp, 'dicId':4 };
 | 
			
		||||
                this.businessLicenseFileList.push(objTwo);
 | 
			
		||||
               })
 | 
			
		||||
            } else {
 | 
			
		||||
| 
						 | 
				
			
			@ -593,6 +611,7 @@ import { forEach } from 'jszip';
 | 
			
		|||
                this.$modal.msgSuccess("新增成功");
 | 
			
		||||
                this.showHouse = false;
 | 
			
		||||
                this.getList();
 | 
			
		||||
                this.delBusinessFileIdList=[];
 | 
			
		||||
                this.businessLicenseListTemp=[];
 | 
			
		||||
                this.businessLicenseFileList=[];
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -605,15 +624,29 @@ import { forEach } from 'jszip';
 | 
			
		|||
                this.$modal.msgSuccess("修改成功");
 | 
			
		||||
                this.showHouse = false;
 | 
			
		||||
                this.getList();
 | 
			
		||||
                this.delBusinessFileIdList=[];
 | 
			
		||||
                this.businessLicenseListTemp=[];
 | 
			
		||||
                this.businessLicenseFileList=[];
 | 
			
		||||
              });
 | 
			
		||||
        },
 | 
			
		||||
 | 
			
		||||
        async deleteFile(){
 | 
			
		||||
            if(this.delBusinessFileIdList.length>0){
 | 
			
		||||
            this.delBusinessFileIdList.forEach(item=>{
 | 
			
		||||
              const objectKey = item;
 | 
			
		||||
              console.log('objectKey',objectKey)
 | 
			
		||||
                deleteFile(objectKey);
 | 
			
		||||
            })
 | 
			
		||||
          }
 | 
			
		||||
        },
 | 
			
		||||
 | 
			
		||||
        // 取消按钮
 | 
			
		||||
        cancel() {
 | 
			
		||||
          this.showHouse = false;
 | 
			
		||||
          this.delBusinessFileIdList=[];
 | 
			
		||||
          this.businessLicenseListTemp=[];
 | 
			
		||||
          this.businessLicenseFileList=[];
 | 
			
		||||
          this.uploadKey = Date.now();
 | 
			
		||||
          this.reset();
 | 
			
		||||
        },
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue