diff --git a/src/app/routes/supply-management/model/import-supply/import-supply.component.html b/src/app/routes/supply-management/model/import-supply/import-supply.component.html index e1746421..38efe00b 100644 --- a/src/app/routes/supply-management/model/import-supply/import-supply.component.html +++ b/src/app/routes/supply-management/model/import-supply/import-supply.component.html @@ -4,42 +4,47 @@ * @Author : Shiming * @Date : 2021-12-03 11:10:14 * @LastEditors : Shiming - * @LastEditTime : 2022-03-02 09:46:36 + * @LastEditTime : 2022-03-02 20:29:46 * @FilePath : \\tms-obc-web\\src\\app\\routes\\supply-management\\model\\import-supply\\import-supply.component.html * Copyright (C) 2022 huzhenhong. All rights reserved. -->
- - - + + + + + + + + + + + [nzAccept]="'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel'" + (nzChange)="handleChange($event)" [nzShowUploadList]="false" [nzBeforeUpload]="beforeUpload" [nzLimit]="1">
-
- 下载导入模板 -
仅支持XLX / XLSX文件格式,最多不能超过100行数据
+ 下载导入模板 +
仅支持XLS / XLSX文件格式,最多不能超过100行数据
- - 注意: - 1、第一次上传请点击下载模板 - 2、请不要调整模板顺序 - 3、必填字段请务必填写 - 4、如果不清楚字段值,请参考货源发布功能 - 5、发布成功后,可在货源列表-待接单查看 - +
+

注意:

+

1、第一次上传请点击下载模板

+

2、请不要调整模板顺序

+

3、必填字段请务必填写

+

4、如果不清楚字段值,请参考货源发布功能

+

5、发布成功后,可在货源列表-待接单查看

+
文件上传成功!成功xx条,失败xx条! diff --git a/src/app/routes/supply-management/model/import-supply/import-supply.component.ts b/src/app/routes/supply-management/model/import-supply/import-supply.component.ts index dfc4fddb..7b22de6e 100644 --- a/src/app/routes/supply-management/model/import-supply/import-supply.component.ts +++ b/src/app/routes/supply-management/model/import-supply/import-supply.component.ts @@ -4,7 +4,7 @@ * @Author : Shiming * @Date : 2022-03-01 15:13:03 * @LastEditors : Shiming - * @LastEditTime : 2022-03-02 10:32:15 + * @LastEditTime : 2022-03-02 20:57:36 * @FilePath : \\tms-obc-web\\src\\app\\routes\\supply-management\\model\\import-supply\\import-supply.component.ts * Copyright (C) 2022 huzhenhong. All rights reserved. */ @@ -18,6 +18,7 @@ import { NzUploadChangeParam, NzUploadFile } from 'ng-zorro-antd/upload'; import { Observable, Observer, of } from 'rxjs'; import { map } from 'rxjs/operators'; import { SupplyManagementService } from '../../services/supply-management.service'; +import { apiConf } from '@conf/api.conf'; @Component({ selector: 'app-supply-management-import-supply', @@ -30,6 +31,8 @@ export class SupplyManagementImportSupplyComponent implements OnInit { files2: any; schema: SFSchema = {}; ui: SFUISchema = {}; + fileName: any; + uploadUrl = apiConf.file_upload_url; @ViewChild('sf', { static: false }) sf!: SFComponent; constructor( private modal: NzModalRef, @@ -70,17 +73,18 @@ export class SupplyManagementImportSupplyComponent implements OnInit { let str =q.replace(/^\s+|\s+$/g,""); if (str) { this.getRegionCode(str); + this.getRegionCode2(str); } } } as SFSelectWidgetSchema }, - resourceCode: { + netTranName: { type: 'string', title: '网络货运人', ui: { - widget: 'select', - placeholder: '请选择' - } as SFSelectWidgetSchema + widget: 'text', + }, + default: '确认货主后带出' }, enterpriseProjectId: { type: 'string', @@ -90,21 +94,29 @@ export class SupplyManagementImportSupplyComponent implements OnInit { placeholder: '请选择' } as SFSelectWidgetSchema }, - resourceCode2: { + fileName: { type: 'string', title: '导入货源信息', ui: { widget: 'custom' } }, + file: { + type: 'string', + title: '', + ui: { + widget: 'custom' + } + }, }, - required: ['shipperAppUserId', 'enterpriseProjectId','resourceCode2',], + required: ['shipperAppUserId', 'enterpriseProjectId','netTranName','fileName'], }; this.ui = { '*': { + spanLabelFixed: 130, grid: { span: 20 }, }, - '$resourceCode2': { + '$fileName': { spanLabelFixed: 130, grid: { span: 20 }, }, @@ -134,22 +146,15 @@ export class SupplyManagementImportSupplyComponent implements OnInit { getRegionCode2(regionCode: any) { console.log(regionCode); return this.service - .request(this.service.$api_getNetworkTransporter, { id: regionCode }) - .pipe( - map(res => - res.map((item: any) => ({ - label: item.projectName, - value: item.id - })) - ) - ) - .subscribe(res => { - // this.sf.getProperty('/enterpriseProjectId')!.schema.enum = res; - // this.sf.getProperty('/enterpriseProjectId')!.widget.reset(res); + .request(this.service.$api_getNetworkTransporter, { id: regionCode }).subscribe((res: any) => { + console.log(res?.netTranName) + console.log(res?.networkTransporter) + this.sf.getProperty('/netTranName')!.widget.reset(res?.netTranName); + this.sf.setValue('/netTranName', res?.netTranName) }); } save(): void { - console.log(this.files) + console.log(this.sf.value) // this.service.request(this.service.$api_update_price, { id, freightType, freightPrice, resourceCode, rule, resourceId }).subscribe(res => { // if (res) { // this.msgSrv.success('保存成功'); @@ -162,33 +167,28 @@ export class SupplyManagementImportSupplyComponent implements OnInit { this.modal.destroy(); } handleChange(info: NzUploadChangeParam): void { - switch (info.file.status) { + switch (info?.file?.status) { case 'uploading': break; case 'done': - let fileList = [...info.fileList]; - // 2. Read from response and show file link - fileList = fileList.map((file: any) => { - if (file.response) { - file.url = file.response.data.fullFilePath; - } - return file; - }); - this.files2 = fileList[0].name + let file = info?.file; + let fileName = file?.response.name; + this.sf?.setValue('/fileName', fileName); + this.sf?.setValue('/file', file?.response?.url); break; case 'error': - this.service.msgSrv.error('网络错误'); + this.service.msgSrv.error('出错误了'); break; } } beforeUpload = (file: NzUploadFile, _fileList: NzUploadFile[]) => { return new Observable((observer: Observer) => { - const isJpgOrPng = file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; - if (!isJpgOrPng) { - this.service.msgSrv.error('仅支持XLX / XLSX文件格式'); - observer.complete(); - return; - } + // const isJpgOrPng = file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; + // if (!isJpgOrPng) { + // this.service.msgSrv.error('仅支持XLX / XLSX文件格式'); + // observer.complete(); + // return; + // } // tslint:disable-next-line: no-non-null-assertion const isLt2M = file.size! / 1024 / 1024 < 3; if (!isLt2M) { @@ -196,10 +196,15 @@ export class SupplyManagementImportSupplyComponent implements OnInit { observer.complete(); return; } - observer.next(isJpgOrPng && isLt2M); + observer.next(isLt2M); observer.complete(); }); }; + clearFile() { + this.fileName = null; + this.sf?.setValue('/fileName', null); + this.sf?.setValue('/file', null); + } downFile() { this.service.downloadFile(this.service.$api_exportGoodsResourceOperateTemplate); } diff --git a/src/conf/api.conf.ts b/src/conf/api.conf.ts index a931ac41..eeea705c 100644 --- a/src/conf/api.conf.ts +++ b/src/conf/api.conf.ts @@ -9,5 +9,9 @@ export const apiConf = { /** * 文件上传路径(水印) */ - waterFileUpload: `/api/mdc/pbc/upload/multipartFile/watermarkFile` + waterFileUpload: `/api/mdc/pbc/upload/multipartFile/watermarkFile`, + /** + * 上传文件,返回fileModel + */ + file_upload_url: '/api/mdc/pbc/upload/multipartFile/fileModel' };