diff --git a/miniprogram/components/mall-panel/index.js b/miniprogram/components/mall-panel/index.js index ff34cb7..240a399 100644 --- a/miniprogram/components/mall-panel/index.js +++ b/miniprogram/components/mall-panel/index.js @@ -267,11 +267,8 @@ Component({ } }, - /** 逐行加工方式(只改方式;仓内/供应商加工由管理员配置) */ - onItemMethodChange(e) { - const index = Number(e.currentTarget.dataset.index); - const pickIndex = Number(e.detail && e.detail.value) || 0; - const method = this.data.processingMethods[pickIndex] || '原材料'; + /** 写入加工方式:列表点选或手输自定义均可。 */ + writeItemMethod(index, method) { const checkoutItem = this.data.checkoutItems[index]; if (!checkoutItem) return; const cart = { ...(this.data.cart || {}) }; @@ -284,10 +281,30 @@ Component({ this.setData({ cart, [`checkoutItems[${index}].processing_method`]: method, - [`checkoutItems[${index}].methodIndex`]: pickIndex, + [`checkoutItems[${index}].methodIndex`]: Math.max( + 0, + this.data.processingMethods.indexOf(method) + ), }); }, + onItemMethodInput(e) { + const index = Number(e.currentTarget.dataset.index); + this.writeItemMethod(index, String((e.detail && e.detail.value) || '').slice(0, 50)); + }, + + onItemMethodBlur(e) { + const index = Number(e.currentTarget.dataset.index); + const method = String((e.detail && e.detail.value) || '').trim().slice(0, 50) || '原材料'; + this.writeItemMethod(index, method); + }, + + onItemMethodChange(e) { + const index = Number(e.currentTarget.dataset.index); + const pickIndex = Number(e.detail && e.detail.value) || 0; + this.writeItemMethod(index, this.data.processingMethods[pickIndex] || '原材料'); + }, + /** 逐行备注 */ onItemRemarkInput(e) { const index = Number(e.currentTarget.dataset.index); diff --git a/miniprogram/components/mall-panel/index.wxml b/miniprogram/components/mall-panel/index.wxml index e00ea54..5aaca84 100644 --- a/miniprogram/components/mall-panel/index.wxml +++ b/miniprogram/components/mall-panel/index.wxml @@ -81,19 +81,28 @@ {{item.name}} - ×{{item.quantity}} + ×{{item.quantity}}{{item.unit}} + ¥{{item.amount}} + - {{item.processing_method}} + ▾ - ¥{{item.amount}}