From baf9ffb611f178a1b7eb989fc49c83c83af5d075 Mon Sep 17 00:00:00 2001 From: Jake Date: Mon, 17 Feb 2020 11:12:50 +0800 Subject: [PATCH] feat(Sku): sku supports message initialization (#5668) --- src/sku/README.md | 5 +++++ src/sku/README.zh-CN.md | 6 ++++++ src/sku/Sku.js | 1 + src/sku/components/SkuMessages.js | 5 ++++- src/sku/demo/index.vue | 3 +++ 5 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/sku/README.md b/src/sku/README.md index b06a668bd..89fc45c18 100644 --- a/src/sku/README.md +++ b/src/sku/README.md @@ -350,6 +350,11 @@ messageConfig: { text: 'xxx', tel: 'xxx', ... + }, + // Key:message name + // Value:message value + initialMessages: { + message: 'message value' } } ``` diff --git a/src/sku/README.zh-CN.md b/src/sku/README.zh-CN.md index c9099bac9..e4b61856a 100644 --- a/src/sku/README.zh-CN.md +++ b/src/sku/README.zh-CN.md @@ -346,6 +346,12 @@ messageConfig: { text: 'xxx', tel: 'xxx', ... + }, + // 初始留言信息 + // 键:留言 name + // 值:留言内容 + initialMessages: { + 留言: '留言信息' } } ``` diff --git a/src/sku/Sku.js b/src/sku/Sku.js index f906c5bae..4667bec08 100644 --- a/src/sku/Sku.js +++ b/src/sku/Sku.js @@ -81,6 +81,7 @@ export default createComponent({ messageConfig: { type: Object, default: () => ({ + initialMessages: {}, placeholderMap: {}, uploadImg: () => Promise.resolve(), uploadMaxSize: 5, diff --git a/src/sku/components/SkuMessages.js b/src/sku/components/SkuMessages.js index 50c12f507..aec1a232b 100644 --- a/src/sku/components/SkuMessages.js +++ b/src/sku/components/SkuMessages.js @@ -35,7 +35,10 @@ export default createComponent({ methods: { resetMessageValues(messages) { - return (messages || []).map(() => ({ value: '' })); + const { messageConfig } = this; + return (messages || []).map(message => ({ + value: messageConfig.initialMessages[message.name] || '', + })); }, getType(message) { diff --git a/src/sku/demo/index.vue b/src/sku/demo/index.vue index b24baf6be..c7a1918d8 100644 --- a/src/sku/demo/index.vue +++ b/src/sku/demo/index.vue @@ -198,6 +198,9 @@ export default { }, }, messageConfig: { + initialMessages: { + 留言1: '商品留言', + }, uploadImg: (file, img) => new Promise(resolve => { setTimeout(() => resolve(img), 1000);