From fe90a52e90e41e6916988c50caa3c63540d588d3 Mon Sep 17 00:00:00 2001
From: peng <peng.com>
Date: 星期四, 16 十月 2025 15:35:09 +0800
Subject: [PATCH] 修改模板
---
seller/src/views/order/order/editTemplateModal.vue | 116 +++++++++++++++++++++++++++++++++-----
seller/src/views/order/order/orderDetail.vue | 63 +++++++++++++++++++-
2 files changed, 158 insertions(+), 21 deletions(-)
diff --git a/seller/src/views/order/order/editTemplateModal.vue b/seller/src/views/order/order/editTemplateModal.vue
index 18e0d4a..6ed906c 100644
--- a/seller/src/views/order/order/editTemplateModal.vue
+++ b/seller/src/views/order/order/editTemplateModal.vue
@@ -86,12 +86,12 @@
</div>
<!-- 璋冭瘯淇℃伅 -->
-<!-- <details style="margin-top: 20px; border: 1px solid #eee; padding: 10px;">-->
-<!-- <summary>璋冭瘯淇℃伅</summary>-->
-<!-- <pre>{{ JSON.stringify(templateData, null, 2) }}</pre>-->
-<!-- <p>閫変腑鐨勫浘鐗嘔D: {{ selectedImageId }}</p>-->
-<!-- <p>琛ㄥ崟鍊�: {{ JSON.stringify(formValues, null, 2) }}</p>-->
-<!-- </details>-->
+<!-- <details style="margin-top: 20px; border: 1px solid #eee; padding: 10px;">
+ <summary>璋冭瘯淇℃伅</summary>
+ <pre>{{ JSON.stringify(templateData, null, 2) }}</pre>
+ <p>閫変腑鐨勫浘鐗嘔D: {{ selectedImageId }}</p>
+ <p>琛ㄥ崟鍊�: {{ JSON.stringify(formValues, null, 2) }}</p>
+ </details>-->
</Form>
<div v-else>
@@ -124,6 +124,11 @@
orderSn: {
type: String,
default: ""
+ },
+ // 娣诲姞userCheckTemplates灞炴��
+ userCheckTemplates: {
+ type: Array,
+ default: () => []
}
},
data() {
@@ -195,8 +200,12 @@
// 澶勭悊妯℃澘鑷畾涔夋爣棰樺瓧娈电殑鍥炴樉
if (res.data.templateConstomizeTitles) {
res.data.templateConstomizeTitles.forEach(item => {
- // 鍥炴樉宸叉湁鐨勫��
- if (item.value !== undefined && item.value !== null) {
+ // 鍥炴樉宸叉湁鐨勫�� - 浠巙serCheckTemplates涓幏鍙栧搴攕ubId鐨勫��
+ const userTemplate = this.getUserTemplateBySubId(item.id);
+ if (userTemplate && userTemplate.content !== undefined && userTemplate.content !== null) {
+ this.$set(this.formValues, item.id, userTemplate.content);
+ } else if (item.value !== undefined && item.value !== null) {
+ // 濡傛灉娌℃湁鎵惧埌userCheckTemplates涓殑鍊硷紝鍒欎娇鐢ㄦā鏉块粯璁ゅ��
this.$set(this.formValues, item.id, item.value);
} else {
// 鍒濆鍖栬〃鍗曞�硷紙濡傛灉娌℃湁榛樿鍊硷級
@@ -213,11 +222,29 @@
// 鏌ユ壘閫変腑鍥剧墖鐨刄RL骞朵繚瀛�
const selectedImage = res.data.templateImgs.find(img => img.id === res.data.chooseImageId);
if (selectedImage) {
- this.selectedImageUrl = selectedImage.imgUrl || '';
+ // 淇敼杩欓噷锛氬鐞嗗浘鐗嘦RL锛屽彧淇濆瓨鐩稿璺緞
+ this.selectedImageUrl = this.processImageUrl(selectedImage.imgUrl || '');
}
} else {
- this.selectedImageId = res.data.templateImgs[0].id;
- this.selectedImageUrl = res.data.templateImgs[0].imgUrl || '';
+ // 灏濊瘯浠巙serCheckTemplates涓幏鍙栭�変腑鐨勫浘鐗�
+ const userTemplate = this.getUserTemplateByType('IMAGE');
+ if (userTemplate && userTemplate.chooseImg) {
+ // 鏌ユ壘瀵瑰簲鐨勫浘鐗嘔D
+ const matchedImage = res.data.templateImgs.find(img => img.imgUrl === userTemplate.chooseImg);
+ if (matchedImage) {
+ this.selectedImageId = matchedImage.id;
+ // 淇敼杩欓噷锛氬鐞嗗浘鐗嘦RL锛屽彧淇濆瓨鐩稿璺緞
+ this.selectedImageUrl = this.processImageUrl(matchedImage.imgUrl || '');
+ } else {
+ this.selectedImageId = res.data.templateImgs[0].id;
+ // 淇敼杩欓噷锛氬鐞嗗浘鐗嘦RL锛屽彧淇濆瓨鐩稿璺緞
+ this.selectedImageUrl = this.processImageUrl(res.data.templateImgs[0].imgUrl || '');
+ }
+ } else {
+ this.selectedImageId = res.data.templateImgs[0].id;
+ // 淇敼杩欓噷锛氬鐞嗗浘鐗嘦RL锛屽彧淇濆瓨鐩稿璺緞
+ this.selectedImageUrl = this.processImageUrl(res.data.templateImgs[0].imgUrl || '');
+ }
}
} else {
// 濡傛灉娌℃湁妯℃澘鍥剧墖锛屾竻绌洪�変腑鐘舵��
@@ -239,6 +266,25 @@
} finally {
this.loading = false;
}
+ },
+
+ // 鏍规嵁subId鑾峰彇userCheckTemplates涓殑瀵瑰簲椤�
+ getUserTemplateBySubId(subId) {
+ // 浠巔rops涓幏鍙杣serCheckTemplates鏁版嵁
+ if (this.userCheckTemplates && this.userCheckTemplates.length > 0) {
+ // 鏌ユ壘subId鍖归厤鐨勯」
+ return this.userCheckTemplates.find(template => template.subId === subId);
+ }
+ return null;
+ },
+
+ // 鏍规嵁绫诲瀷鑾峰彇userCheckTemplates涓殑瀵瑰簲椤�
+ getUserTemplateByType(contentType) {
+ if (this.userCheckTemplates && this.userCheckTemplates.length > 0) {
+ // 鏌ユ壘contentType鍖归厤鐨勯」
+ return this.userCheckTemplates.find(template => template.contentType === contentType);
+ }
+ return null;
},
// 鑾峰彇鍥剧墖URL
@@ -282,7 +328,8 @@
if (this.templateData && this.templateData.templateImgs) {
const selectedImage = this.templateData.templateImgs.find(img => img.id === imageId);
if (selectedImage) {
- this.selectedImageUrl = selectedImage.imgUrl || '';
+ // 淇敼杩欓噷锛氬鐞嗗浘鐗嘦RL锛屽彧淇濆瓨鐩稿璺緞
+ this.selectedImageUrl = this.processImageUrl(selectedImage.imgUrl || '');
} else {
this.selectedImageUrl = '';
}
@@ -326,7 +373,7 @@
console.log('涓婁紶鏂囦欢杩斿洖缁撴灉:', res); // 娣诲姞璋冭瘯鏃ュ織
if (res.code === 200) {
// 涓婁紶鎴愬姛锛岃缃〃鍗曞��
- // 纭繚res.data鏄瓧绗︿覆绫诲瀷
+ // 淇敼杩欓噷锛氬彧淇濆瓨鏂囦欢鍚嶆垨鐩稿璺緞锛岃�屼笉鏄畬鏁磋矾寰�
let fileKey = '';
if (typeof res.data === 'string') {
fileKey = res.data;
@@ -342,7 +389,21 @@
fileKey = String(fileKey);
}
+ // 淇敼杩欓噷锛氬鐞嗘枃浠惰矾寰勶紝鍙繚鐣欐枃浠跺悕閮ㄥ垎
+ // 濡傛灉鏄畬鏁碪RL锛屽垯鍙彇璺緞閮ㄥ垎锛涘惁鍒欎繚鎸佸師鏍�
+ if (fileKey.startsWith('http://') || fileKey.startsWith('https://')) {
+ // 鎻愬彇URL涓殑璺緞閮ㄥ垎
+ try {
+ const urlObj = new URL(fileKey);
+ fileKey = urlObj.pathname.substring(1); // 鍘绘帀寮�澶寸殑鏂滄潬
+ } catch (e) {
+ // 濡傛灉URL瑙f瀽澶辫触锛屼繚鎸佸師鏍�
+ console.warn('Failed to parse URL:', fileKey);
+ }
+ }
+
this.$set(this.formValues, fieldId, fileKey);
+
this.$Message.success("鍥剧墖涓婁紶鎴愬姛");
// 寮哄埗鏇存柊瑙嗗浘浠ョ‘淇濆浘鐗囬瑙堟纭樉绀�
@@ -373,7 +434,8 @@
sn: this.orderSn,
templateName: this.form.templateName,
chooseImageId: this.selectedImageId,
- chooseImage: this.selectedImageUrl, // 娣诲姞閫変腑鍥剧墖URL
+ // 淇敼杩欓噷锛氬鐞哻hooseImage锛屽彧淇濆瓨鐩稿璺緞
+ chooseImage: this.processImageUrl(this.selectedImageUrl),
templateForm: []
};
@@ -384,13 +446,35 @@
id: item.id,
templateTitle: item.templateTitle,
contentType: item.contentType,
- value: this.formValues[item.id] || ""
+ // 淇敼杩欓噷锛氬鐞唙alue锛屽彧淇濆瓨鐩稿璺緞
+ value: this.processImageUrl(this.formValues[item.id]) || ""
});
});
}
console.log("鎻愪氦鍙傛暟:", params);
return params;
+ },
+
+ // 澶勭悊鍥剧墖URL锛屽彧淇濈暀鐩稿璺緞
+ processImageUrl(url) {
+ if (!url || typeof url !== 'string') {
+ return url;
+ }
+
+ // 濡傛灉鏄畬鏁碪RL锛屽垯鍙彇璺緞閮ㄥ垎锛涘惁鍒欎繚鎸佸師鏍�
+ if (url.startsWith('http://') || url.startsWith('https://')) {
+ try {
+ const urlObj = new URL(url);
+ return urlObj.pathname.substring(1); // 鍘绘帀寮�澶寸殑鏂滄潬
+ } catch (e) {
+ // 濡傛灉URL瑙f瀽澶辫触锛屼繚鎸佸師鏍�
+ console.warn('Failed to parse URL:', url);
+ return url;
+ }
+ }
+
+ return url;
},
// 纭畾鎸夐挳
@@ -523,4 +607,4 @@
border-color: #57a3f3;
color: #57a3f3;
}
-</style>
+</style>
\ No newline at end of file
diff --git a/seller/src/views/order/order/orderDetail.vue b/seller/src/views/order/order/orderDetail.vue
index 8c04378..15e21c4 100644
--- a/seller/src/views/order/order/orderDetail.vue
+++ b/seller/src/views/order/order/orderDetail.vue
@@ -18,8 +18,8 @@
v-if="allowOperation.ship && logisticsType != 'SHUNFENG'">鎵撳嵃鐢靛瓙闈㈠崟</Button>
<Button @click="modifyRemark" type="primary">娣诲姞澶囨敞</Button>
<!-- 灏嗙紪杈戞ā鏉挎寜閽Щ鍒拌繖閲� -->
- <Button v-if="orderInfo.userCheckTemplates && orderInfo.userCheckTemplates.length > 0"
- @click="editTemplateInfo(orderInfo.userCheckTemplates[0].templateId, sn)"
+ <Button v-if="orderInfo.userCheckTemplates && orderInfo.userCheckTemplates.length > 0"
+ @click="editTemplateInfo(orderInfo.userCheckTemplates[0].templateId, sn)"
type="primary">缂栬緫妯℃澘</Button>
</div>
</Card>
@@ -169,7 +169,7 @@
<div class="div-item-right">
<img
v-if="item.chooseImg"
- :src="item.chooseImg"
+ :src="getImageUrl(item.chooseImg)"
alt="閫夋嫨鐨勫浘鐗�"
class="selected-img"
style="max-width: 200px; max-height: 150px;"
@@ -192,7 +192,7 @@
<!-- 姝e垯鍒ゆ柇锛歝ontent 浠� http/https 寮�澶� 鈫� 娓叉煋鍥剧墖锛涘惁鍒欐覆鏌撴枃鏈� -->
<img
v-if="isUrl(item.content)"
- :src="item.content"
+ :src="getImageUrl(item.content)"
alt="鍐呭鍥剧墖"
class="content-img"
style="max-width: 200px; max-height: 150px;"
@@ -648,6 +648,7 @@
v-model="editTemplateModalVisible"
:template-id="currentTemplateId"
:order-sn="sn"
+ :user-check-templates="orderInfo.userCheckTemplates"
@success="handleTemplateEditSuccess"
@cancel="editTemplateModalVisible = false"
/>
@@ -658,6 +659,7 @@
import * as API_Order from "@/api/order";
import * as API_Logistics from "@/api/logistics";
import * as RegExp from "@/libs/RegExp.js";
+import { getSts } from "@/api/file";
import multipleMap from "@/views/my-components/map/multiple-map";
import EditTemplateModal from "./editTemplateModal.vue";
@@ -685,6 +687,7 @@
},
submitLoading: false, // 娣诲姞鎴栫紪杈戞彁浜ょ姸鎬�
logisticsType: 'KUAIDINIAO', //鐗╂祦绫诲瀷
+ endpoint: '', // 娣诲姞endpoint鍙橀噺鐢ㄤ簬瀛樺偍STS endpoint
someJSONdata: '',
faceSheetForm: {
@@ -1026,7 +1029,9 @@
packageTraceList: [],
// 娣诲姞妯℃澘缂栬緫寮圭獥鐩稿叧鏁版嵁
editTemplateModalVisible: false,
- currentTemplateId: ""
+ currentTemplateId: "",
+ // 鐢ㄤ簬浼犻�抲serCheckTemplates鏁版嵁缁欏瓙缁勪欢
+ userCheckTemplates: []
};
},
methods: {
@@ -1040,6 +1045,31 @@
// 5. \.(jpg|jpeg|png|gif|bmp|webp)$ 锛氫粎鍖归厤甯歌鍥剧墖鍚庣紑锛屽拷鐣ュぇ灏忓啓锛坕鏍囧織锛�
const imgReg = /^https?:\/\/([\w-]+\.)+[a-zA-Z]{2,}(\/[\w-./?%&=]*)*\.(jpg|jpeg|png|gif|bmp|webp)$/i;
return imgReg.test(str);
+ },
+ // 鑾峰彇鍥剧墖URL锛堜娇鐢⊿TS鑾峰彇鐨別ndpoint锛�
+ getImageUrl(fileKey) {
+ // 纭繚fileKey鏄瓧绗︿覆绫诲瀷
+ if (!fileKey || typeof fileKey !== 'string') {
+ console.warn('fileKey is not a valid string:', fileKey);
+ return ''; // 杩斿洖绌哄瓧绗︿覆鎴栭粯璁ゅ浘鐗�
+ }
+
+ // 瀹夊叏妫�鏌tartsWith鏂规硶鏄惁瀛樺湪
+ if (fileKey.startsWith && typeof fileKey.startsWith === 'function' &&
+ (fileKey.startsWith("http://") || fileKey.startsWith("https://"))) {
+ return fileKey;
+ }
+
+ // 濡傛灉鏈塭ndpoint閰嶇疆锛屼娇鐢╡ndpoint鎷兼帴URL
+ if (this.endpoint) {
+ // 纭繚fileKey涓嶄互/寮�澶达紝endpoint涓嶄互/缁撳熬
+ const cleanEndpoint = this.endpoint.replace(/\/$/, '');
+ const cleanFileKey = fileKey.replace(/^\//, '');
+ return `${cleanEndpoint}/${cleanFileKey}`;
+ }
+
+ // 鍚﹀垯杩斿洖fileKey锛岃缁勪欢鑷繁澶勭悊
+ return fileKey;
},
// 閫変腑
selectGroupShipGoodsMethods (selected) {
@@ -1436,6 +1466,18 @@
})
},
+ // 鑾峰彇STS淇℃伅
+ // async getStsInfo() {
+ // try {
+ // const stsRes = await getSts();
+ // if (stsRes.success) {
+ // this.endpoint = stsRes.data.endpoint;
+ // }
+ // } catch (error) {
+ // console.error('鑾峰彇STS淇℃伅澶辫触:', error);
+ // }
+ // },
+
// 缂栬緫妯℃澘淇℃伅
editTemplateInfo(templateId, orderSn) {
console.log("璋冪敤editTemplateInfo锛屽弬鏁�:", {
@@ -1443,6 +1485,8 @@
orderSn: orderSn
});
this.currentTemplateId = templateId;
+ // 鏇存柊userCheckTemplates鏁版嵁
+ this.userCheckTemplates = this.orderInfo.userCheckTemplates || [];
this.editTemplateModalVisible = true;
},
@@ -1453,6 +1497,14 @@
this.$Message.success("妯℃澘淇℃伅宸叉洿鏂�");
// 鍒锋柊璁㈠崟璇︽儏椤甸潰鏁版嵁
this.getDataDetail();
+ },
+
+ getStsInfo() {
+ getSts().then(res => {
+ if (res.code==200) {
+ this.endpoint = res.data.endpoint;
+ }
+ });
}
},
mounted () {
@@ -1460,6 +1512,7 @@
this.getDataDetail();
this.getLogisticsSetting();
this.getOrderPackage();
+ this.getStsInfo(); // 娣诲姞杩欒鏉ヨ幏鍙朣TS淇℃伅
},
// 濡傛灉鏄粠璇︽儏椤佃繑鍥炲垪琛ㄩ〉锛屼慨鏀瑰垪琛ㄩ〉keepAlive涓簍rue锛岀‘淇濅笉鍒锋柊椤甸潰
beforeRouteLeave (to, from, next) {
--
Gitblit v1.8.0