From 50de7480237de2ba9d140a219d48a9b72211b8d2 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期四, 03 九月 2026 17:27:43 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev_business' into dev_business
---
yudao-ui/yudao-ui-admin-vue3/src/views/srm/supplier/index.vue | 113 ++++++++++
yudao-module-srm/src/main/java/cn/iocoder/yudao/module/srm/controller/admin/supplier/vo/SrmSupplierImportRespVO.java | 24 ++
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/transfer/MesWmTransferServiceImpl.java | 8
yudao-module-srm/src/main/java/cn/iocoder/yudao/module/srm/service/supplier/SrmSupplierService.java | 11 +
yudao-module-srm/src/main/java/cn/iocoder/yudao/module/srm/controller/admin/supplier/vo/SrmSupplierImportExcelVO.java | 71 ++++++
yudao-module-srm/src/main/java/cn/iocoder/yudao/module/srm/enums/ErrorCodeConstants.java | 1
yudao-module-srm/src/main/java/cn/iocoder/yudao/module/srm/controller/admin/supplier/SrmSupplierController.java | 78 ++++++
docs/srm_supplier_import_export_integration.md | 116 ++++++++++
yudao-module-srm/src/main/java/cn/iocoder/yudao/module/srm/controller/admin/supplier/vo/SrmSupplierExcelVO.java | 74 ++++++
yudao-module-srm/src/main/java/cn/iocoder/yudao/module/srm/service/supplier/SrmSupplierServiceImpl.java | 115 ++++++++++
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/transfer/vo/MesWmTransferSaveReqVO.java | 3
yudao-ui/yudao-ui-admin-vue3/src/api/srm/supplier/index.ts | 8
12 files changed, 613 insertions(+), 9 deletions(-)
diff --git a/docs/srm_supplier_import_export_integration.md b/docs/srm_supplier_import_export_integration.md
new file mode 100644
index 0000000..5125baf
--- /dev/null
+++ b/docs/srm_supplier_import_export_integration.md
@@ -0,0 +1,116 @@
+# SRM 渚涘簲鍟嗘。妗� 瀵煎嚭 / 瀵煎叆 - 鍓嶇鑱旇皟鏂规
+
+## 娑夊強椤甸潰
+
+| 椤甸潰 | 鍓嶇缁勪欢 | 鍚庣鎺ュ彛鍓嶇紑 | 璇存槑 |
+|------|----------|--------------|------|
+| 渚涘簲鍟嗘。妗� | `srm/supplier/index`锛堢粍浠跺悕 SrmSupplier锛� | `/srm/supplier` | 鏂板"瀵煎嚭銆佸鍏ャ�佷笅杞芥ā鏉�"宸ュ叿鏍忓叆鍙� |
+
+## 鏉冮檺锛堟寜閽樉闅愶紝涓庡悗绔� @PreAuthorize 涓�鑷达級
+
+| 鎿嶄綔 | 鎸夐挳鏉冮檺 | 鍚庣鎺ュ彛鏍¢獙 |
+|------|----------|--------------|
+| 瀵煎嚭 | `srm:supplier:export` | `/srm/supplier/export-excel` |
+| 涓嬭浇妯℃澘 / 瀵煎叆 | `srm:supplier:import` | `/srm/supplier/get-import-template`銆乣/srm/supplier/import-excel` |
+
+> 鏂版寜閽彍鍗� SQL 瑙� `sql/mysql/srm_supplier_import_export_menu.sql`锛堝箓绛夛紝鍚櫘閫氳鑹叉巿鏉冿級锛涜秴绾х鐞嗗憳鑷姩鎷ユ湁鍏ㄩ儴鑿滃崟銆�
+> 鑻ュ巻鍙插簱涓� `srm:supplier:export` 鎸夐挳鑿滃崟宸插瓨鍦ㄤ絾瑙掕壊鏈垎閰嶏紝鎵ц璇ヨ剼鏈嵆鍙ˉ榻愩��
+
+## API 涓�瑙�
+
+| 鏂规硶 | 璺緞 | 璇存槑 | 鏉冮檺 |
+|------|------|------|------|
+| GET | `/srm/supplier/export-excel` | 鎸夊綋鍓嶅垪琛ㄦ煡璇㈡潯浠跺鍑哄叏閮ㄥ懡涓锛堜笉鍒嗛〉锛� | 瀵煎嚭鏉冮檺 |
+| GET | `/srm/supplier/get-import-template` | 涓嬭浇瀵煎叆妯℃澘锛堝惈 1 琛岀ず渚嬫暟鎹紝鍙垹鍚庡~鍐欙級 | 瀵煎叆鏉冮檺 |
+| POST | `/srm/supplier/import-excel` | 涓婁紶 Excel 瀵煎叆锛坢ultipart锛� | 瀵煎叆鏉冮檺 |
+
+### 瀵煎叆鎺ュ彛鍙傛暟
+
+| 鍙傛暟 | 绫诲瀷 | 蹇呭~ | 璇存槑 |
+|------|------|------|------|
+| file | MultipartFile | 鏄� | 寰呭鍏ョ殑 Excel锛�.xls/.xlsx锛� |
+| updateSupport | Boolean | 鍚� | 鏄惁鏀寔鏇存柊锛歚true`=鎸�"渚涘簲鍟嗙紪鐮�"宸插瓨鍦ㄥ垯鏇存柊锛涢粯璁� `false`=浠呮柊澧烇紝宸插瓨鍦ㄥ垯璇ヨ鎶�"渚涘簲鍟嗙紪鐮佸凡瀛樺湪" |
+
+### 瀵煎叆鍝嶅簲缁撴瀯
+
+`code: 0` 琛ㄧず鎺ュ彛鎵ц瀹屾垚锛堥潪 0 涓哄弬鏁�/绯荤粺寮傚父锛夈�備笟鍔″眰鐨勯儴鍒嗘垚鍔熼�氳繃 `data` 杩斿洖锛�
+
+```json
+{
+ "code": 0,
+ "data": {
+ "createList": ["鏂板鎴愬姛鐨勪緵搴斿晢鍚嶇О"],
+ "updateList": ["鏇存柊鎴愬姛鐨勪緵搴斿晢鍚嶇О"],
+ "failureList": { "澶辫触鐨勪緵搴斿晢鍚嶇О": "澶辫触鍘熷洜" }
+ }
+}
+```
+
+> 鍓嶇绾﹀畾锛歚failureList` 闈炵┖鍗宠涓�"閮ㄥ垎澶辫触"锛屽簲寮圭獥閫愯鎻愮ず澶辫触鍘熷洜锛沗createList`/`updateList` 鐢ㄤ簬姹囨�绘彁绀�"鎴愬姛鏂板 x 鏉°�佹洿鏂� y 鏉�"銆�
+
+## 瀵煎嚭鎺ュ彛
+
+- 澶嶇敤鍒楄〃鏌ヨ杩囨护鏉′欢锛圙ET 鏌ヨ鍙傛暟锛歝ode/name/type/status/contactName/contactMobile锛夛紝瀵煎嚭鍏ㄩ儴鍛戒腑琛岋紝鏃犻渶浼犻〉鐮併��
+- 鎴愬姛杩斿洖浜岃繘鍒舵枃浠舵祦锛屾枃浠跺悕锛歚渚涘簲鍟嗘暟鎹�.xlsx`锛涘け璐ユ椂鍙兘杩斿洖 HTTP 200 + JSON锛岄渶鍖哄垎浜岃繘鍒朵笌 JSON銆�
+- 瀵煎嚭琛ㄥご涓轰腑鏂囷紝**绫诲瀷鍒楁樉绀哄悕绉帮紙鐢熶骇鍨�/璐告槗鍨�/鏈嶅姟鍨�/鍏朵粬锛夛紝鐘舵�佸垪鏄剧ず 鍚敤/绂佺敤**锛堜笌椤甸潰鏍囩涓�鑷达級锛屼究浜庨槄璇伙細
+
+| 鍒楀悕 | 瀵瑰簲瀛楁 | 璇存槑 |
+|------|----------|------|
+| 渚涘簲鍟嗙紪鐮� | code | |
+| 渚涘簲鍟嗗悕绉� | name | |
+| 渚涘簲鍟嗙畝绉� | shortName | |
+| 渚涘簲鍟嗙被鍨� | type | 瀵煎嚭涓轰腑鏂囧悕绉� |
+| 浼佷笟鎬ц川 | companyNature | |
+| 娉ㄥ唽璧勯噾(涓囧厓) | registeredCapital | |
+| 钀ヤ笟鎵х収缂栧彿 | businessLicenseNo | |
+| 绋庡彿 | taxNo | |
+| 娉曚汉浠h〃 | legalPerson | |
+| 鍏徃鍦板潃 | address | |
+| 鍏徃缃戝潃 | website | |
+| 鑱旂郴浜� | contactName | |
+| 鑱旂郴鐢佃瘽 | contactMobile | |
+| 閭 | contactEmail | |
+| 寮�鎴烽摱琛� | bankName | |
+| 閾惰璐﹀彿 | bankAccount | |
+| 鐘舵�� | status | 瀵煎嚭涓� 鍚敤/绂佺敤 |
+| 澶囨敞 | remark | |
+| 鍒涘缓鏃堕棿 | createTime | |
+
+> 璇存槑锛氭鍓嶅鍑虹洿鎺ヤ娇鐢� `SrmSupplierRespVO` 杈撳嚭锛岃〃澶翠负鑻辨枃瀛楁鍚嶏紱鏈鏀归�犱负鐙珛 `SrmSupplierExcelVO`锛岃〃澶翠笌鍙栧�煎彛寰勫彉鍖栧涓婏紝瀵煎嚭鏂囦欢涓嶅彲鐩存帴鍥炲锛堝洖瀵艰鐢ㄥ鍏ユā鏉匡級銆�
+
+## 瀵煎叆妯℃澘璇存槑锛堜笟鍔¤鍒欙級
+
+涓嬭浇妯℃澘鏂囦欢鍚嶏細`渚涘簲鍟嗗鍏ユā鏉�.xlsx`锛屽唴鍚� 1 琛岀ず渚嬫暟鎹紙鍙垹闄ゅ悗鏁磋〃濉啓锛夈��
+
+| 鍒楀悕 | 蹇呭~ | 濉啓瑙勫垯 |
+|------|------|----------|
+| 渚涘簲鍟嗙紪鐮� | 鏄� | 鍏ㄥ眬鍞竴锛岄噸澶嶇紪鐮佹寜 `updateSupport` 鍐冲畾鎶ラ敊鎴栨洿鏂� |
+| 渚涘簲鍟嗗悕绉� | 鏄� | |
+| 渚涘簲鍟嗙畝绉� | 鍚� | |
+| 渚涘簲鍟嗙被鍨�(鐢熶骇鍨�/璐告槗鍨�/鏈嶅姟鍨�/鍏朵粬) | 鍚� | 鍙~涓枃鍚嶇О鎴栫紪鐮� 1/2/3/4锛涙棤娉曡瘑鍒椂鎸夊師鏍蜂繚瀛� |
+| 浼佷笟鎬ц川(鍥戒紒/姘戣惀/澶栬祫/鍚堣祫) | 鍚� | 濉疄闄呮枃鏈� |
+| 娉ㄥ唽璧勯噾(涓囧厓) | 鍚� | 鏁板�� |
+| 钀ヤ笟鎵х収缂栧彿 / 绋庡彿 | 鍚� | |
+| 娉曚汉浠h〃 | 鍚� | |
+| 鍏徃鍦板潃 / 鍏徃缃戝潃 | 鍚� | |
+| 鑱旂郴浜� / 鑱旂郴鐢佃瘽 / 閭 | 鍚� | |
+| 寮�鎴烽摱琛� / 閾惰璐﹀彿 | 鍚� | |
+| 鐘舵��(0鍚敤/1绂佺敤) | 鍚� | 濉� 0/1锛涚暀绌洪粯璁� 0锛堝惎鐢級 |
+| 澶囨敞 | 鍚� | |
+
+琛岀骇澶勭悊瑙勫垯锛�
+
+| 鍦烘櫙 | 瑙勫垯 |
+|------|------|
+| 缂栫爜鎴栧悕绉颁负绌� | 璇ヨ澶辫触锛�"渚涘簲鍟嗙紪鐮佸拰渚涘簲鍟嗗悕绉颁笉鑳戒负绌�" |
+| 缂栫爜宸插瓨鍦� 涓� updateSupport=false | 璇ヨ澶辫触锛�"渚涘簲鍟嗙紪鐮佸凡瀛樺湪" |
+| 缂栫爜宸插瓨鍦� 涓� updateSupport=true | 鏇存柊璇ヤ緵搴斿晢妗f |
+| 缂栫爜涓嶅瓨鍦� | 鏂板渚涘簲鍟嗘。妗� |
+| 鍗曡鍏跺畠鏍¢獙寮傚父锛堝缂栫爜鍞竴鍐茬獊锛� | 璇ヨ澶辫触骞惰褰曞師鍥狅紝涓嶅奖鍝嶅叾瀹冭瀵煎叆 |
+
+## 娉ㄦ剰浜嬮」
+
+1. 寤鸿鍦ㄤ緵搴斿晢妗f宸ュ叿鏍忓鍔�"瀵煎叆""涓嬭浇妯℃澘"涓や釜鍏ュ彛锛涘鍏ヤ氦浜掗渶鍖呭惈 `updateSupport` 閫夐」锛堝閫夋"鏇存柊宸插瓨鍦ㄧ殑渚涘簲鍟�"锛岄粯璁や笉鍕鹃�夛級锛屽鍏ョ粨鏋滄寜涓婃枃鍝嶅簲缁撴瀯缁欏嚭鎴愬姛/澶辫触姹囨�讳笌澶辫触鍘熷洜銆�
+2. "瀵煎嚭"鎸夐挳鐜版湁瀹炵幇淇濇寔涓嶅彉锛坄export-excel`锛夛紝浠呭悗绔緭鍑哄垪/琛ㄥご浼樺寲銆�
+3. 渚涘簲鍟嗘暟鎹彲閫氳繃鍑嗗叆瀹℃壒鑷姩鍒涘缓锛屾绫昏褰曞彲鑳界己灏戠紪鐮�/绫诲瀷锛屽鍏ユā鏉夸笉鍙楀奖鍝嶏紙鎸夌紪鐮佸尮閰嶏紝绌虹紪鐮佷笉褰卞搷鏃㈡湁鏁版嵁锛夈��
+4. 鏉冮檺璇存槑锛氭ā鏉夸笅杞戒笌瀵煎叆浣跨敤鍚屼竴鏉冮檺 `srm:supplier:import`銆�
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/transfer/vo/MesWmTransferSaveReqVO.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/transfer/vo/MesWmTransferSaveReqVO.java
index cf44709..47449ce 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/transfer/vo/MesWmTransferSaveReqVO.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/transfer/vo/MesWmTransferSaveReqVO.java
@@ -28,8 +28,7 @@
@NotNull(message = "杞Щ鍗曠被鍨嬩笉鑳戒负绌�")
private Integer type;
- @Schema(description = "鏄惁閰嶉��", requiredMode = REQUIRED, example = "true")
- @NotNull(message = "鏄惁閰嶉�佷笉鑳戒负绌�")
+ @Schema(description = "鏄惁閰嶉��", example = "true")
private Boolean deliveryFlag;
@Schema(description = "鏀惰揣浜�", example = "寮犱笁")
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/transfer/MesWmTransferServiceImpl.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/transfer/MesWmTransferServiceImpl.java
index f9d5110..6dc6d6a 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/transfer/MesWmTransferServiceImpl.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/transfer/MesWmTransferServiceImpl.java
@@ -59,6 +59,10 @@
// 鎻掑叆
MesWmTransferDO transfer = BeanUtils.toBean(createReqVO, MesWmTransferDO.class);
transfer.setStatus(MesWmTransferStatusEnum.PREPARE.getStatus());
+ // 鍐呴儴璋冩嫧锛堟垨鏈�夋嫨閰嶉�佹ā寮忥級鏃朵笉浼犫�滄槸鍚﹂厤閫佲�濓紝缁熶竴鎸夐潪閰嶉�佸鐞嗭紝閬垮厤蹇呭~鏍¢獙鎷︽埅
+ if (transfer.getDeliveryFlag() == null) {
+ transfer.setDeliveryFlag(false);
+ }
transferMapper.insert(transfer);
return transfer.getId();
}
@@ -72,6 +76,10 @@
// 鏇存柊
MesWmTransferDO updateObj = BeanUtils.toBean(updateReqVO, MesWmTransferDO.class);
+ // 鍐呴儴璋冩嫧锛堟垨鏈�夋嫨閰嶉�佹ā寮忥級鏃跺墠绔笉浼犫�滄槸鍚﹂厤閫佲�濓紝缁熶竴鎸夐潪閰嶉�佸鐞嗭紝閬垮厤蹇呭~鏍¢獙鎷︽埅
+ if (updateObj.getDeliveryFlag() == null) {
+ updateObj.setDeliveryFlag(false);
+ }
transferMapper.updateById(updateObj);
}
diff --git a/yudao-module-srm/src/main/java/cn/iocoder/yudao/module/srm/controller/admin/supplier/SrmSupplierController.java b/yudao-module-srm/src/main/java/cn/iocoder/yudao/module/srm/controller/admin/supplier/SrmSupplierController.java
index c0b71d8..85770d4 100644
--- a/yudao-module-srm/src/main/java/cn/iocoder/yudao/module/srm/controller/admin/supplier/SrmSupplierController.java
+++ b/yudao-module-srm/src/main/java/cn/iocoder/yudao/module/srm/controller/admin/supplier/SrmSupplierController.java
@@ -7,6 +7,7 @@
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.module.srm.controller.admin.supplier.vo.*;
import cn.iocoder.yudao.module.srm.dal.dataobject.SrmSupplierDO;
+import cn.iocoder.yudao.module.srm.enums.SupplierTypeEnum;
import cn.iocoder.yudao.module.srm.service.supplier.SrmSupplierService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
@@ -17,8 +18,11 @@
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@@ -88,12 +92,82 @@
}
@GetMapping("/export-excel")
- @Operation(summary = "瀵煎嚭渚涘簲鍟� Excel")
+ @Operation(summary = "瀵煎嚭渚涘簲鍟嗘。妗� Excel")
@PreAuthorize("@ss.hasPermission('srm:supplier:export')")
public void exportSupplierExcel(@Valid SrmSupplierPageReqVO pageReqVO, HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
+ // 澶嶇敤鍒嗛〉杩囨护鏉′欢锛屽鍑哄唴瀹逛笌鍒楄〃涓�鑷�
List<SrmSupplierDO> list = supplierService.getSupplierPage(pageReqVO).getList();
- ExcelUtils.write(response, "渚涘簲鍟嗘暟鎹�.xlsx", "渚涘簲鍟�", SrmSupplierRespVO.class, BeanUtils.toBean(list, SrmSupplierRespVO.class));
+ List<SrmSupplierExcelVO> excelList = new ArrayList<>();
+ for (SrmSupplierDO supplier : list) {
+ SrmSupplierExcelVO excelVO = BeanUtils.toBean(supplier, SrmSupplierExcelVO.class);
+ excelVO.setType(toTypeLabel(supplier.getType()));
+ excelVO.setStatus(toStatusLabel(supplier.getStatus()));
+ excelList.add(excelVO);
+ }
+ ExcelUtils.write(response, "渚涘簲鍟嗘暟鎹�.xlsx", "渚涘簲鍟�", SrmSupplierExcelVO.class, excelList);
+ }
+
+ @GetMapping("/get-import-template")
+ @Operation(summary = "鑾峰緱瀵煎叆渚涘簲鍟嗘。妗堟ā鏉�")
+ @PreAuthorize("@ss.hasPermission('srm:supplier:import')")
+ public void getImportTemplate(HttpServletResponse response) throws IOException {
+ SrmSupplierImportExcelVO sample = new SrmSupplierImportExcelVO();
+ sample.setCode("GYS0001");
+ sample.setName("绀轰緥渚涘簲鍟�");
+ sample.setShortName("绀轰緥");
+ sample.setType("鐢熶骇鍨�");
+ sample.setCompanyNature("姘戣惀");
+ sample.setRegisteredCapital(new java.math.BigDecimal("1000"));
+ sample.setBusinessLicenseNo("91320000XXXXXXXXXX");
+ sample.setTaxNo("91320000XXXXXXXXXX");
+ sample.setLegalPerson("寮犱笁");
+ sample.setAddress("绀轰緥甯傜ず渚嬪尯绀轰緥璺�1鍙�");
+ sample.setWebsite("http://www.example.com");
+ sample.setContactName("鏉庡洓");
+ sample.setContactMobile("13800000000");
+ sample.setContactEmail("contact@example.com");
+ sample.setBankName("绀轰緥閾惰绀轰緥鏀");
+ sample.setBankAccount("6222020000000000000");
+ sample.setStatus(0);
+ sample.setRemark("瀵煎叆妯℃澘绀轰緥琛岋紝鍙垹闄�");
+ ExcelUtils.write(response, "渚涘簲鍟嗗鍏ユā鏉�.xlsx", "渚涘簲鍟�", SrmSupplierImportExcelVO.class, Arrays.asList(sample));
+ }
+
+ @PostMapping("/import-excel")
+ @Operation(summary = "瀵煎叆渚涘簲鍟嗘。妗� Excel")
+ @PreAuthorize("@ss.hasPermission('srm:supplier:import')")
+ public CommonResult<SrmSupplierImportRespVO> importSupplierExcel(@RequestParam("file") MultipartFile file,
+ @RequestParam(value = "updateSupport", required = false, defaultValue = "false") Boolean updateSupport) throws Exception {
+ List<SrmSupplierImportExcelVO> list = ExcelUtils.read(file, SrmSupplierImportExcelVO.class);
+ return success(supplierService.importSupplierList(list, updateSupport));
+ }
+
+ // ========== Excel 灞曠ず杈呭姪 ==========
+
+ /**
+ * 渚涘簲鍟嗙被鍨嬬紪鐮� -> 涓枃鍚嶇О锛堝 1 -> 鐢熶骇鍨嬶級锛涙棤娉曡瘑鍒椂鍘熸牱杩斿洖
+ */
+ private static String toTypeLabel(String typeCode) {
+ if (typeCode == null) {
+ return null;
+ }
+ for (SupplierTypeEnum e : SupplierTypeEnum.values()) {
+ if (typeCode.equals(String.valueOf(e.getCode()))) {
+ return e.getName();
+ }
+ }
+ return typeCode;
+ }
+
+ /**
+ * 鐘舵�� 0 鍚敤 / 1 绂佺敤 -> 涓枃鏂囨锛涚┖鍊艰繑鍥炵┖
+ */
+ private static String toStatusLabel(Integer status) {
+ if (status == null) {
+ return null;
+ }
+ return status == 0 ? "鍚敤" : "绂佺敤";
}
}
diff --git a/yudao-module-srm/src/main/java/cn/iocoder/yudao/module/srm/controller/admin/supplier/vo/SrmSupplierExcelVO.java b/yudao-module-srm/src/main/java/cn/iocoder/yudao/module/srm/controller/admin/supplier/vo/SrmSupplierExcelVO.java
new file mode 100644
index 0000000..df038ac
--- /dev/null
+++ b/yudao-module-srm/src/main/java/cn/iocoder/yudao/module/srm/controller/admin/supplier/vo/SrmSupplierExcelVO.java
@@ -0,0 +1,74 @@
+package cn.iocoder.yudao.module.srm.controller.admin.supplier.vo;
+
+import cn.idev.excel.annotation.ExcelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+/**
+ * SRM 渚涘簲鍟嗘。妗堝鍑� Excel VO
+ *
+ * 涓庡垪琛ㄥ睍绀哄彛寰勪竴鑷达紱绫诲瀷銆佺姸鎬佸垪瀵煎嚭涓哄彲璇绘枃鏈紙濡� 鐢熶骇鍨� / 鍚敤锛夛紝鏂逛究涓氬姟闃呰
+ */
+@Data
+public class SrmSupplierExcelVO {
+
+ @ExcelProperty("渚涘簲鍟嗙紪鐮�")
+ private String code;
+
+ @ExcelProperty("渚涘簲鍟嗗悕绉�")
+ private String name;
+
+ @ExcelProperty("渚涘簲鍟嗙畝绉�")
+ private String shortName;
+
+ @ExcelProperty("渚涘簲鍟嗙被鍨�")
+ private String type;
+
+ @ExcelProperty("浼佷笟鎬ц川")
+ private String companyNature;
+
+ @ExcelProperty("娉ㄥ唽璧勯噾(涓囧厓)")
+ private BigDecimal registeredCapital;
+
+ @ExcelProperty("钀ヤ笟鎵х収缂栧彿")
+ private String businessLicenseNo;
+
+ @ExcelProperty("绋庡彿")
+ private String taxNo;
+
+ @ExcelProperty("娉曚汉浠h〃")
+ private String legalPerson;
+
+ @ExcelProperty("鍏徃鍦板潃")
+ private String address;
+
+ @ExcelProperty("鍏徃缃戝潃")
+ private String website;
+
+ @ExcelProperty("鑱旂郴浜�")
+ private String contactName;
+
+ @ExcelProperty("鑱旂郴鐢佃瘽")
+ private String contactMobile;
+
+ @ExcelProperty("閭")
+ private String contactEmail;
+
+ @ExcelProperty("寮�鎴烽摱琛�")
+ private String bankName;
+
+ @ExcelProperty("閾惰璐﹀彿")
+ private String bankAccount;
+
+ @ExcelProperty("鐘舵��")
+ private String status;
+
+ @ExcelProperty("澶囨敞")
+ private String remark;
+
+ @ExcelProperty("鍒涘缓鏃堕棿")
+ private LocalDateTime createTime;
+
+}
diff --git a/yudao-module-srm/src/main/java/cn/iocoder/yudao/module/srm/controller/admin/supplier/vo/SrmSupplierImportExcelVO.java b/yudao-module-srm/src/main/java/cn/iocoder/yudao/module/srm/controller/admin/supplier/vo/SrmSupplierImportExcelVO.java
new file mode 100644
index 0000000..3ed98fc
--- /dev/null
+++ b/yudao-module-srm/src/main/java/cn/iocoder/yudao/module/srm/controller/admin/supplier/vo/SrmSupplierImportExcelVO.java
@@ -0,0 +1,71 @@
+package cn.iocoder.yudao.module.srm.controller.admin.supplier.vo;
+
+import cn.idev.excel.annotation.ExcelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * SRM 渚涘簲鍟嗘。妗堝鍏� Excel VO
+ *
+ * 缂栫爜銆佸悕绉颁负蹇呭~锛涚被鍨嬫敮鎸佸~涓枃鍚嶇О锛堢敓浜у瀷/璐告槗鍨�/鏈嶅姟鍨�/鍏朵粬锛夋垨缂栫爜锛�1/2/3/4锛夛紱
+ * 鐘舵�� 0=鍚敤銆�1=绂佺敤锛岀暀绌洪粯璁ゅ惎鐢�
+ */
+@Data
+public class SrmSupplierImportExcelVO {
+
+ @ExcelProperty("渚涘簲鍟嗙紪鐮�")
+ private String code;
+
+ @ExcelProperty("渚涘簲鍟嗗悕绉�")
+ private String name;
+
+ @ExcelProperty("渚涘簲鍟嗙畝绉�")
+ private String shortName;
+
+ @ExcelProperty("渚涘簲鍟嗙被鍨�(鐢熶骇鍨�/璐告槗鍨�/鏈嶅姟鍨�/鍏朵粬)")
+ private String type;
+
+ @ExcelProperty("浼佷笟鎬ц川(鍥戒紒/姘戣惀/澶栬祫/鍚堣祫)")
+ private String companyNature;
+
+ @ExcelProperty("娉ㄥ唽璧勯噾(涓囧厓)")
+ private BigDecimal registeredCapital;
+
+ @ExcelProperty("钀ヤ笟鎵х収缂栧彿")
+ private String businessLicenseNo;
+
+ @ExcelProperty("绋庡彿")
+ private String taxNo;
+
+ @ExcelProperty("娉曚汉浠h〃")
+ private String legalPerson;
+
+ @ExcelProperty("鍏徃鍦板潃")
+ private String address;
+
+ @ExcelProperty("鍏徃缃戝潃")
+ private String website;
+
+ @ExcelProperty("鑱旂郴浜�")
+ private String contactName;
+
+ @ExcelProperty("鑱旂郴鐢佃瘽")
+ private String contactMobile;
+
+ @ExcelProperty("閭")
+ private String contactEmail;
+
+ @ExcelProperty("寮�鎴烽摱琛�")
+ private String bankName;
+
+ @ExcelProperty("閾惰璐﹀彿")
+ private String bankAccount;
+
+ @ExcelProperty("鐘舵��(0鍚敤/1绂佺敤)")
+ private Integer status;
+
+ @ExcelProperty("澶囨敞")
+ private String remark;
+
+}
diff --git a/yudao-module-srm/src/main/java/cn/iocoder/yudao/module/srm/controller/admin/supplier/vo/SrmSupplierImportRespVO.java b/yudao-module-srm/src/main/java/cn/iocoder/yudao/module/srm/controller/admin/supplier/vo/SrmSupplierImportRespVO.java
new file mode 100644
index 0000000..c70d4c7
--- /dev/null
+++ b/yudao-module-srm/src/main/java/cn/iocoder/yudao/module/srm/controller/admin/supplier/vo/SrmSupplierImportRespVO.java
@@ -0,0 +1,24 @@
+package cn.iocoder.yudao.module.srm.controller.admin.supplier.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Builder;
+import lombok.Data;
+
+import java.util.List;
+import java.util.Map;
+
+@Schema(description = "绠$悊鍚庡彴 - SRM 渚涘簲鍟嗗鍏� Response VO")
+@Data
+@Builder
+public class SrmSupplierImportRespVO {
+
+ @Schema(description = "鏂板鎴愬姛鐨勪緵搴斿晢鍚嶇О鏁扮粍", requiredMode = Schema.RequiredMode.REQUIRED)
+ private List<String> createList;
+
+ @Schema(description = "鏇存柊鎴愬姛鐨勪緵搴斿晢鍚嶇О鏁扮粍", requiredMode = Schema.RequiredMode.REQUIRED)
+ private List<String> updateList;
+
+ @Schema(description = "瀵煎叆澶辫触鐨勪緵搴斿晢闆嗗悎 key 涓轰緵搴斿晢鍚嶇О锛寁alue 涓哄け璐ュ師鍥�", requiredMode = Schema.RequiredMode.REQUIRED)
+ private Map<String, String> failureList;
+
+}
diff --git a/yudao-module-srm/src/main/java/cn/iocoder/yudao/module/srm/enums/ErrorCodeConstants.java b/yudao-module-srm/src/main/java/cn/iocoder/yudao/module/srm/enums/ErrorCodeConstants.java
index fb42aa5..d0a3d7f 100644
--- a/yudao-module-srm/src/main/java/cn/iocoder/yudao/module/srm/enums/ErrorCodeConstants.java
+++ b/yudao-module-srm/src/main/java/cn/iocoder/yudao/module/srm/enums/ErrorCodeConstants.java
@@ -14,6 +14,7 @@
ErrorCode SUPPLIER_EXISTS_REFERENCE = new ErrorCode(1_040_100_002, "渚涘簲鍟嗚涓氬姟寮曠敤锛屾棤娉曞垹闄�");
ErrorCode SUPPLIER_CONTACT_NOT_EXISTS = new ErrorCode(1_040_100_003, "渚涘簲鍟嗚仈绯讳汉涓嶅瓨鍦�");
ErrorCode SUPPLIER_NOT_ENABLE = new ErrorCode(1_040_100_004, "渚涘簲鍟嗗凡鍋滅敤锛屾棤娉曞弬涓庢姇鏍�");
+ ErrorCode SUPPLIER_IMPORT_LIST_IS_EMPTY = new ErrorCode(1_040_100_005, "瀵煎叆鐨勪緵搴斿晢鏁版嵁涓嶈兘涓虹┖");
// ========== 渚涘簲鍟嗗噯鍏� 1_040_200_000 ==========
ErrorCode APPLY_NOT_EXISTS = new ErrorCode(1_040_200_000, "鍑嗗叆鐢宠涓嶅瓨鍦�");
diff --git a/yudao-module-srm/src/main/java/cn/iocoder/yudao/module/srm/service/supplier/SrmSupplierService.java b/yudao-module-srm/src/main/java/cn/iocoder/yudao/module/srm/service/supplier/SrmSupplierService.java
index 2b8783d..d73b842 100644
--- a/yudao-module-srm/src/main/java/cn/iocoder/yudao/module/srm/service/supplier/SrmSupplierService.java
+++ b/yudao-module-srm/src/main/java/cn/iocoder/yudao/module/srm/service/supplier/SrmSupplierService.java
@@ -1,6 +1,8 @@
package cn.iocoder.yudao.module.srm.service.supplier;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.module.srm.controller.admin.supplier.vo.SrmSupplierImportExcelVO;
+import cn.iocoder.yudao.module.srm.controller.admin.supplier.vo.SrmSupplierImportRespVO;
import cn.iocoder.yudao.module.srm.controller.admin.supplier.vo.SrmSupplierPageReqVO;
import cn.iocoder.yudao.module.srm.controller.admin.supplier.vo.SrmSupplierSaveReqVO;
import cn.iocoder.yudao.module.srm.dal.dataobject.SrmSupplierDO;
@@ -41,6 +43,15 @@
PageResult<SrmSupplierDO> getSupplierPage(SrmSupplierPageReqVO pageReqVO);
/**
+ * 鎵归噺瀵煎叆渚涘簲鍟嗘。妗�
+ *
+ * @param importList 瀵煎叆鏁版嵁
+ * @param updateSupport 鏄惁鏇存柊宸插瓨鍦ㄧ殑渚涘簲鍟嗭紙鎸夌紪鐮佸垽鏂級锛宖alse 鏃堕噸澶嶇紪鐮佽涓哄け璐�
+ * @return 瀵煎叆缁撴灉锛堟柊澧�/鏇存柊/澶辫触 鏄庣粏锛�
+ */
+ SrmSupplierImportRespVO importSupplierList(List<SrmSupplierImportExcelVO> importList, Boolean updateSupport);
+
+ /**
* 鑾峰彇渚涘簲鍟嗗垪琛紙浠呰繑鍥炲凡閫氳繃鍑嗗叆瀹℃壒鐨勪緵搴斿晢锛岀敤浜庝笅鎷夐�夋嫨锛�
*/
List<SrmSupplierDO> getSupplierSimpleList();
diff --git a/yudao-module-srm/src/main/java/cn/iocoder/yudao/module/srm/service/supplier/SrmSupplierServiceImpl.java b/yudao-module-srm/src/main/java/cn/iocoder/yudao/module/srm/service/supplier/SrmSupplierServiceImpl.java
index 6c4c50f..129d4fa 100644
--- a/yudao-module-srm/src/main/java/cn/iocoder/yudao/module/srm/service/supplier/SrmSupplierServiceImpl.java
+++ b/yudao-module-srm/src/main/java/cn/iocoder/yudao/module/srm/service/supplier/SrmSupplierServiceImpl.java
@@ -1,10 +1,15 @@
package cn.iocoder.yudao.module.srm.service.supplier;
import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
+import cn.iocoder.yudao.framework.common.exception.ServiceException;
+import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.iocoder.yudao.module.srm.controller.admin.supplier.vo.SrmSupplierImportExcelVO;
+import cn.iocoder.yudao.module.srm.controller.admin.supplier.vo.SrmSupplierImportRespVO;
import cn.iocoder.yudao.module.srm.controller.admin.supplier.vo.SrmSupplierPageReqVO;
import cn.iocoder.yudao.module.srm.controller.admin.supplier.vo.SrmSupplierSaveReqVO;
import cn.iocoder.yudao.module.srm.dal.dataobject.*;
@@ -17,18 +22,19 @@
import cn.iocoder.yudao.module.srm.dal.mysql.SrmSupplierMapper;
import cn.iocoder.yudao.module.srm.dal.mysql.SrmTenderBidMapper;
import cn.iocoder.yudao.module.srm.enums.ErrorCodeConstants;
-import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil;
+import cn.iocoder.yudao.module.srm.enums.SupplierTypeEnum;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;
-import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
-
-import cn.hutool.core.collection.CollUtil;
+import java.math.BigDecimal;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.LinkedHashMap;
import java.util.List;
+import java.util.Map;
@Service
@Validated
@@ -104,6 +110,49 @@
}
@Override
+ @Transactional(rollbackFor = Exception.class)
+ public SrmSupplierImportRespVO importSupplierList(List<SrmSupplierImportExcelVO> importList, Boolean updateSupport) {
+ if (CollUtil.isEmpty(importList)) {
+ throw ServiceExceptionUtil.exception(ErrorCodeConstants.SUPPLIER_IMPORT_LIST_IS_EMPTY);
+ }
+ SrmSupplierImportRespVO respVO = SrmSupplierImportRespVO.builder()
+ .createList(new ArrayList<>())
+ .updateList(new ArrayList<>())
+ .failureList(new LinkedHashMap<>())
+ .build();
+ // 閫愯瀵煎叆锛氬崟琛屽け璐ヨ褰曞埌 failureList锛屼笉褰卞搷鍏跺畠琛�
+ for (SrmSupplierImportExcelVO importVO : importList) {
+ String code = StrUtil.trim(importVO.getCode());
+ String name = StrUtil.trim(importVO.getName());
+ if (StrUtil.isBlank(code) || StrUtil.isBlank(name)) {
+ respVO.getFailureList().put(StrUtil.blankToDefault(name, code), "渚涘簲鍟嗙紪鐮佸拰渚涘簲鍟嗗悕绉颁笉鑳戒负绌�");
+ continue;
+ }
+ SrmSupplierSaveReqVO saveReqVO = toSaveReqVO(importVO);
+ try {
+ SrmSupplierDO existByCode = supplierMapper.selectByCode(code);
+ if (existByCode != null) {
+ if (!Boolean.TRUE.equals(updateSupport)) {
+ respVO.getFailureList().put(name, "渚涘簲鍟嗙紪鐮佸凡瀛樺湪");
+ continue;
+ }
+ saveReqVO.setId(existByCode.getId());
+ updateSupplier(saveReqVO);
+ respVO.getUpdateList().add(name);
+ } else {
+ createSupplier(saveReqVO);
+ respVO.getCreateList().add(name);
+ }
+ } catch (Exception ex) {
+ // 鍗曟潯澶辫触锛岃褰曞苟缁х画
+ String reason = ex instanceof ServiceException ? ((ServiceException) ex).getMessage() : ex.getMessage();
+ respVO.getFailureList().put(name, reason == null ? "瀵煎叆澶辫触" : reason);
+ }
+ }
+ return respVO;
+ }
+
+ @Override
public List<SrmSupplierDO> getSupplierSimpleList() {
return supplierMapper.selectApprovedList();
}
@@ -126,6 +175,64 @@
return supplierMapper.selectBatchIds(ids);
}
+ // ========== 瀵煎叆杈呭姪鏂规硶 ==========
+
+ /**
+ * 瀵煎叆 VO -> 淇濆瓨 VO锛屽鐢� create/update 閫昏緫锛�
+ * 绫诲瀷鏀寔涓枃鍚嶇О鎴栫紪鐮侊紙1~4锛夛紝鐘舵�佺暀绌洪粯璁ゅ惎鐢�
+ */
+ private SrmSupplierSaveReqVO toSaveReqVO(SrmSupplierImportExcelVO importVO) {
+ SrmSupplierSaveReqVO saveReqVO = new SrmSupplierSaveReqVO();
+ saveReqVO.setCode(StrUtil.trim(importVO.getCode()));
+ saveReqVO.setName(StrUtil.trim(importVO.getName()));
+ saveReqVO.setShortName(StrUtil.trimToNull(importVO.getShortName()));
+ saveReqVO.setType(parseTypeCode(importVO.getType()));
+ saveReqVO.setCompanyNature(StrUtil.trimToNull(importVO.getCompanyNature()));
+ saveReqVO.setRegisteredCapital(importVO.getRegisteredCapital());
+ saveReqVO.setBusinessLicenseNo(StrUtil.trimToNull(importVO.getBusinessLicenseNo()));
+ saveReqVO.setTaxNo(StrUtil.trimToNull(importVO.getTaxNo()));
+ saveReqVO.setLegalPerson(StrUtil.trimToNull(importVO.getLegalPerson()));
+ saveReqVO.setAddress(StrUtil.trimToNull(importVO.getAddress()));
+ saveReqVO.setWebsite(StrUtil.trimToNull(importVO.getWebsite()));
+ saveReqVO.setContactName(StrUtil.trimToNull(importVO.getContactName()));
+ saveReqVO.setContactMobile(StrUtil.trimToNull(importVO.getContactMobile()));
+ saveReqVO.setContactEmail(StrUtil.trimToNull(importVO.getContactEmail()));
+ saveReqVO.setBankName(StrUtil.trimToNull(importVO.getBankName()));
+ saveReqVO.setBankAccount(StrUtil.trimToNull(importVO.getBankAccount()));
+ saveReqVO.setStatus(importVO.getStatus() != null ? importVO.getStatus() : CommonStatusEnum.ENABLE.getStatus());
+ saveReqVO.setRemark(StrUtil.trimToNull(importVO.getRemark()));
+ return saveReqVO;
+ }
+
+ /**
+ * 渚涘簲鍟嗙被鍨嬭В鏋愶細涓枃鍚嶇О鎴栫紪鐮侊紙1~4锛夊潎杞崲涓虹紪鐮佸瓧绗︿覆锛�
+ * 鏃犳硶璇嗗埆鏃朵繚鐣欏師鍊硷紝閬垮厤瀵煎叆琚樆濉�
+ */
+ private String parseTypeCode(String type) {
+ String t = StrUtil.trimToNull(type);
+ if (t == null) {
+ return null;
+ }
+ for (SupplierTypeEnum e : SupplierTypeEnum.values()) {
+ if (t.equalsIgnoreCase(e.getName()) || t.equals(String.valueOf(e.getCode()))) {
+ return String.valueOf(e.getCode());
+ }
+ }
+ // 鍏煎 Excel 鏁板瓧鍗曞厓鏍艰璇绘垚 "1.0" 绛夊甫灏忔暟褰㈠紡
+ try {
+ BigDecimal bd = new BigDecimal(t);
+ if (bd.stripTrailingZeros().scale() <= 0) {
+ int i = bd.intValueExact();
+ if (i >= 1 && i <= 4) {
+ return String.valueOf(i);
+ }
+ }
+ } catch (NumberFormatException ignored) {
+ // 蹇界暐锛氫繚鎸佸師鍊�
+ }
+ return t;
+ }
+
// ========== 鏍¢獙鏂规硶 ==========
private void validateSupplierExists(Long id) {
diff --git a/yudao-ui/yudao-ui-admin-vue3/src/api/srm/supplier/index.ts b/yudao-ui/yudao-ui-admin-vue3/src/api/srm/supplier/index.ts
index 0e3d5c1..f40ff08 100644
--- a/yudao-ui/yudao-ui-admin-vue3/src/api/srm/supplier/index.ts
+++ b/yudao-ui/yudao-ui-admin-vue3/src/api/srm/supplier/index.ts
@@ -67,6 +67,14 @@
exportSupplierExcel: async (params: any) =>
request.download({ url: '/srm/supplier/export-excel', params }),
+ // 涓嬭浇瀵煎叆妯℃澘
+ getImportTemplate: async () =>
+ request.download({ url: '/srm/supplier/get-import-template' }),
+
+ // 瀵煎叆 Excel锛坒ormData 闇�鍖呭惈 file銆乽pdateSupport锛�
+ importSupplierExcel: async (formData: any) =>
+ request.upload({ url: '/srm/supplier/import-excel', data: formData }),
+
// 鑱旂郴浜哄垪琛�
getContactList: async (supplierId: number) =>
request.get({ url: '/srm/supplier-contact/list-by-supplier', params: { supplierId } }),
diff --git a/yudao-ui/yudao-ui-admin-vue3/src/views/srm/supplier/index.vue b/yudao-ui/yudao-ui-admin-vue3/src/views/srm/supplier/index.vue
index 2bc257a..b5cbb74 100644
--- a/yudao-ui/yudao-ui-admin-vue3/src/views/srm/supplier/index.vue
+++ b/yudao-ui/yudao-ui-admin-vue3/src/views/srm/supplier/index.vue
@@ -26,6 +26,9 @@
<el-button type="primary" plain @click="openForm()" v-hasPermi="['srm:supplier:create']">
<Icon icon="ep:plus" class="mr-5px" /> 鏂板
</el-button>
+ <el-button type="warning" plain @click="handleImport" v-hasPermi="['srm:supplier:import']">
+ <Icon icon="ep:upload" class="mr-5px" /> 瀵煎叆
+ </el-button>
<el-button type="success" plain @click="handleExport" :loading="exportLoading" v-hasPermi="['srm:supplier:export']">
<Icon icon="ep:download" class="mr-5px" /> 瀵煎嚭
</el-button>
@@ -198,10 +201,43 @@
<el-descriptions-item label="澶囨敞" :span="2">{{ detailData.remark }}</el-descriptions-item>
</el-descriptions>
</el-dialog>
+
+ <!-- 瀵煎叆瀵硅瘽妗� -->
+ <el-dialog title="渚涘簲鍟嗘。妗堝鍏�" v-model="importVisible" width="440px" @closed="resetImport">
+ <el-upload
+ ref="importUploadRef"
+ v-model:file-list="fileList"
+ :auto-upload="false"
+ :disabled="importLoading"
+ :limit="1"
+ :on-exceed="handleImportExceed"
+ accept=".xlsx, .xls"
+ action="none"
+ drag
+ >
+ <Icon icon="ep:upload" />
+ <div class="el-upload__text">灏嗘枃浠舵嫋鍒版澶勶紝鎴�<em>鐐瑰嚮涓婁紶</em></div>
+ <template #tip>
+ <div class="el-upload__tip text-center">
+ <div class="el-upload__tip">
+ <el-checkbox v-model="updateSupport" />
+ 鏄惁鏇存柊宸茬粡瀛樺湪鐨勪緵搴斿晢锛堟寜渚涘簲鍟嗙紪鐮佸垽鏂級
+ </div>
+ <span>浠呭厑璁稿鍏� xls銆亁lsx 鏍煎紡鏂囦欢銆�</span>
+ <el-link :underline="false" style="font-size: 12px; vertical-align: baseline" type="primary" @click="handleDownloadTemplate">涓嬭浇妯℃澘</el-link>
+ </div>
+ </template>
+ </el-upload>
+ <template #footer>
+ <el-button :disabled="importLoading" type="primary" @click="handleImportSubmit">纭� 瀹�</el-button>
+ <el-button @click="importVisible = false">鍙� 娑�</el-button>
+ </template>
+ </el-dialog>
</template>
<script setup lang="ts">
import { dateFormatter } from '@/utils/formatTime'
+import download from '@/utils/download'
import { SrmSupplierApi, SrmSupplierVO, SrmSupplierContactVO } from '@/api/srm/supplier'
defineOptions({ name: 'SrmSupplier' })
@@ -318,13 +354,88 @@
try {
await message.exportConfirm()
exportLoading.value = true
- await SrmSupplierApi.exportSupplierExcel(queryParams)
+ const data = await SrmSupplierApi.exportSupplierExcel(queryParams)
+ download.excel(data, '渚涘簲鍟嗘暟鎹�.xlsx')
} catch {
} finally {
exportLoading.value = false
}
}
+// ========== 瀵煎叆 ==========
+const importVisible = ref(false)
+const importLoading = ref(false)
+const importUploadRef = ref()
+const fileList = ref<any[]>([])
+const updateSupport = ref(false)
+
+/** 鎵撳紑瀵煎叆寮圭獥 */
+const handleImport = () => {
+ resetImport()
+ importVisible.value = true
+}
+
+/** 涓嬭浇瀵煎叆妯℃澘 */
+const handleDownloadTemplate = async () => {
+ try {
+ const data = await SrmSupplierApi.getImportTemplate()
+ download.excel(data, '渚涘簲鍟嗗鍏ユā鏉�.xlsx')
+ } catch {
+ }
+}
+
+/** 涓婁紶鏂囦欢鏁伴噺瓒呴檺 */
+const handleImportExceed = () => {
+ message.error('鏈�澶氬彧鑳戒笂浼犱竴涓枃浠讹紒')
+}
+
+/** 閲嶇疆瀵煎叆鐘舵�� */
+const resetImport = () => {
+ importLoading.value = false
+ fileList.value = []
+ updateSupport.value = false
+ importUploadRef.value?.clearFiles()
+}
+
+/** 鎻愪氦瀵煎叆 */
+const handleImportSubmit = async () => {
+ if (fileList.value.length === 0) {
+ message.error('璇蜂笂浼犳枃浠�')
+ return
+ }
+ importLoading.value = true
+ try {
+ const formData = new FormData()
+ formData.append('updateSupport', updateSupport.value ? 'true' : 'false')
+ formData.append('file', fileList.value[0].raw as Blob)
+ const res = await SrmSupplierApi.importSupplierExcel(formData)
+ if (res.code !== 0) {
+ message.error(res.msg)
+ return
+ }
+ // 姹囨�诲鍏ョ粨鏋滐細鏂板/鏇存柊/澶辫触
+ const data = res.data || {}
+ const createList = data.createList || []
+ const updateList = data.updateList || []
+ const failureList = data.failureList || {}
+ let text = '鎴愬姛鏂板鏁伴噺锛�' + createList.length + '锛�'
+ text += '鎴愬姛鏇存柊鏁伴噺锛�' + updateList.length + '锛�'
+ text += '澶辫触鏁伴噺锛�' + Object.keys(failureList).length + '銆�'
+ const failureNames = Object.keys(failureList)
+ for (const name of failureNames) {
+ text += '銆�' + name + '锛�' + failureList[name] + '銆�'
+ }
+ message.alert(text)
+ importVisible.value = false
+ await getList()
+ } catch {
+ message.error('涓婁紶澶辫触锛岃鎮ㄩ噸鏂颁笂浼狅紒')
+ } finally {
+ importLoading.value = false
+ resetImport()
+ }
+}
+
onMounted(() => {
getList()
})
--
Gitblit v1.9.3